SimpleObjectPool 1.0.1

SimpleObjectPool 1.0.1

TestsTested
LangLanguage Obj-CObjective C
License Apache 2
ReleasedLast Release Mar 2017

Maintained by Paul Melnikow.



  • By
  • Paul Melnikow

Simple implementation of a thread-safe object pool.

Pool

Usage

When the pool is empty, it naively creates another object using the createBlock.

ObjectPool *pool = [ObjectPool poolWithCreateBlock:^id(NSError **outError) {
    NSLog(@"Opening database connection");
    MyDBConnection *connection = [MyDBConnection connection]
    if (![connection openWithError:outError])
        return nil;
    else
        return connection;
}];

MyDBConnection *connection = [pool objectFromPoolWithError:nil];

// do stuff with connection

[pool returnObjectToPool:connection];

Installation

Install via CocoaPods.

Contribute

Pull requests welcome!

Support

If you are having issues, please let me know.

Development

This project includes unit tests. To run them, run pod install inside the TestProject folder, then load the workspace and execute the test action.

License

This project is licensed under the Apache license.