AWSFMDatabasePool
Objective-C
@interface AWSFMDatabasePool : NSObject {
NSString *_path;
dispatch_queue_t _lockQueue;
NSMutableArray *_databaseInPool;
NSMutableArray *_databaseOutPool;
id _delegate;
NSUInteger _maximumNumberOfDatabasesToCreate;
int _openFlags;
}
Swift
class AWSFMDatabasePool : NSObject
Pool of <FMDatabase> objects.
### See also
<FMDatabaseQueue><FMDatabase>
Warning
Before using FMDatabasePool, please consider using <FMDatabaseQueue> instead.
If you really really really know what you’re doing and FMDatabasePool is what
you really really need (ie, you’re using a read only database), OK you can use
it. But just be careful not to deadlock!
For an example on deadlocking, search for:
ONLY_USE_THE_POOL_IF_YOU_ARE_DOING_READS_OTHERWISE_YOULL_DEADLOCK_USE_FMDATABASEQUEUE_INSTEAD
in the main.m file.
-
Undocumented
Declaration
Objective-C
NSString *_path -
Undocumented
Declaration
Objective-C
dispatch_queue_t _lockQueue -
Undocumented
Declaration
Objective-C
NSMutableArray *_databaseInPool -
Undocumented
Declaration
Objective-C
NSMutableArray *_databaseOutPool -
Undocumented
Declaration
Objective-C
__unsafe_unretained id _delegate -
Undocumented
Declaration
Objective-C
NSUInteger _maximumNumberOfDatabasesToCreate -
Undocumented
Declaration
Objective-C
int _openFlags -
Database path
Declaration
Objective-C
@property (retain) NSString *path;Swift
var path: String! { get set } -
Delegate object
Declaration
Objective-C
@property id delegate;Swift
unowned(unsafe) var delegate: AnyObject! { get set } -
Maximum number of databases to create
Declaration
Objective-C
@property NSUInteger maximumNumberOfDatabasesToCreate;Swift
var maximumNumberOfDatabasesToCreate: UInt { get set } -
Open flags
Declaration
Objective-C
@property (readonly) int openFlags;Swift
var openFlags: Int32 { get }
-
Create pool using path.
Declaration
Objective-C
+ (instancetype)databasePoolWithPath:(NSString *)aPath;Parameters
aPathThe file path of the database.
Return Value
The
FMDatabasePoolobject.nilon error. -
Create pool using path and specified flags
Declaration
Objective-C
+ (instancetype)databasePoolWithPath:(NSString *)aPath flags:(int)openFlags;Parameters
aPathThe file path of the database.
openFlagsFlags passed to the openWithFlags method of the database
Return Value
The
FMDatabasePoolobject.nilon error. -
Create pool using path.
Declaration
Objective-C
- (instancetype)initWithPath:(NSString *)aPath;Swift
init!(path aPath: String!)Parameters
aPathThe file path of the database.
Return Value
The
FMDatabasePoolobject.nilon error. -
Create pool using path and specified flags.
Declaration
Objective-C
- (instancetype)initWithPath:(NSString *)aPath flags:(int)openFlags;Swift
init!(path aPath: String!, flags openFlags: Int32)Parameters
aPathThe file path of the database.
openFlagsFlags passed to the openWithFlags method of the database
Return Value
The
FMDatabasePoolobject.nilon error.
-
Number of checked-in databases in pool
@returns Number of databases
Declaration
Objective-C
- (NSUInteger)countOfCheckedInDatabases;Swift
func countOfCheckedInDatabases() -> UInt -
Number of checked-out databases in pool
@returns Number of databases
Declaration
Objective-C
- (NSUInteger)countOfCheckedOutDatabases;Swift
func countOfCheckedOutDatabases() -> UInt -
Total number of databases in pool
@returns Number of databases
Declaration
Objective-C
- (NSUInteger)countOfOpenDatabases;Swift
func countOfOpenDatabases() -> UInt -
Release all databases in pool
Declaration
Objective-C
- (void)releaseAllDatabases;Swift
func releaseAllDatabases()
-
Synchronously perform database operations in pool.
Declaration
Objective-C
- (void)inDatabase:(void (^)(AWSFMDatabase *))block;Swift
func inDatabase(_ block: ((AWSFMDatabase?) -> Void)!)Parameters
blockThe code to be run on the
FMDatabasePoolpool. -
Synchronously perform database operations in pool using transaction.
Declaration
Objective-C
- (void)inTransaction:(void (^)(AWSFMDatabase *, BOOL *))block;Swift
func inTransaction(_ block: ((AWSFMDatabase?, UnsafeMutablePointer<ObjCBool>?) -> Void)!)Parameters
blockThe code to be run on the
FMDatabasePoolpool. -
Synchronously perform database operations in pool using deferred transaction.
Declaration
Objective-C
- (void)inDeferredTransaction:(void (^)(AWSFMDatabase *, BOOL *))block;Swift
func inDeferredTransaction(_ block: ((AWSFMDatabase?, UnsafeMutablePointer<ObjCBool>?) -> Void)!)Parameters
blockThe code to be run on the
FMDatabasePoolpool. -
Synchronously perform database operations in pool using save point.
Warning
You can not nest these, since calling it will pull another database out of the pool and you’ll get a deadlock. If you need to nest, use
<[FMDatabase startSavePointWithName:error:]>instead.Declaration
Objective-C
- (NSError *)inSavePoint:(void (^)(AWSFMDatabase *, BOOL *))block;Swift
func inSavePoint(_ block: ((AWSFMDatabase?, UnsafeMutablePointer<ObjCBool>?) -> Void)!) -> Error!Parameters
blockThe code to be run on the
FMDatabasePoolpool.Return Value
NSErrorobject if error;nilif successful.
-
Convenience method to create a database pool with the SQLITE_OPEN_FULLMUTEX flag so it can be safely accessed across threads.
Declaration
Objective-C
+ (nonnull instancetype)serialDatabasePoolWithPath:(nonnull NSString *)aPath;Swift
class func serialDatabasePool(withPath aPath: String) -> SelfParameters
aPathThe file path of the database.
Return Value
The
FMDatabasePoolobject.nilon error.
View on GitHub
Install in Dash
AWSFMDatabasePool Class Reference