https://github.com/paulmelnikow/simpleobjectpool
Simple thread-safe object pool in Objective-C
https://github.com/paulmelnikow/simpleobjectpool
factory pool
Last synced: 10 months ago
JSON representation
Simple thread-safe object pool in Objective-C
- Host: GitHub
- URL: https://github.com/paulmelnikow/simpleobjectpool
- Owner: paulmelnikow
- License: apache-2.0
- Created: 2013-06-12T15:06:23.000Z (about 13 years ago)
- Default Branch: master
- Last Pushed: 2017-03-18T03:29:36.000Z (over 9 years ago)
- Last Synced: 2025-08-24T13:14:37.889Z (10 months ago)
- Topics: factory, pool
- Language: Objective-C
- Size: 735 KB
- Stars: 12
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
SimpleObjectPool
================
Simple implementation of a thread-safe object pool.
[](http://cocoapods.org/pods/SimpleObjectPool)
[](http://cocoapods.org/pods/SimpleObjectPool)
[](http://cocoapods.org/pods/SimpleObjectPool)
[](https://travis-ci.org/paulmelnikow/SimpleObjectPool)

Usage
-----
When the pool is empty, it naively creates another object using the
createBlock.
```objc
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][project].
[project]: https://cocoapods.org/pods/SimpleObjectPool
Contribute
----------
- Issue Tracker: https://github.com/paulmelnikow/SimpleObjectPool/issues
- Source Code: https://github.com/paulmelnikow/SimpleObjectPool
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.
[httpbin]: https://httpbin.org/
License
-------
This project is licensed under the Apache license.