Latest | 0.1.0 |
---|---|
Homepage | https://github.com/jiakai-lian/JKLThreadSafeOperator |
License | MIT |
Platforms | ios 7.0, requires ARC |
Authors |
[](https://travis-ci.org/Jiakai Lian/JKLThreadSafeOperator)
Make a class thread-safe could be painful, as involving wrapping all your public methods into GCD operations.
This operator is designated to perform thread-safe operations by simply wrapping read & write operations into corresponding blocks. (For performance comparision between different implementations, please check another repo ThreadSafeClassDesign). So without changing original model classes, the project could benefit from multi-threading without compromising the stability.
The main idea behind the scene is applying concurrent read and exclusive write model on a concurrent GCD queue. Additionally, this operator maintains a simple cache to manage queues for each type of class.
Run Example Projects
To run the example project, clone the repo, and run pod
install from the Example directory first.
Usage
Read Operation
__block NSUInteger studentsCount;
[JKLThreadSafeOperator syncReadWithObject:course readBlock:^(JKLCourse * innerReadOnlyCourse) {
studentsCount = [innerReadOnlyCourse students].count;
}];
Write Operation
[JKLThreadSafeOperator barrierAsyncWriteWithObject:course writeBlock:^(JKLCourse * innerWritableCourse) {
[innerWritableCourse addStudentWithStudentName:@"Bob"];
}];
Requirements
Installation
JKLThreadSafeOperator is available through CocoaPods. To install
it, simply add the following line to your Podfile:
pod "JKLThreadSafeOperator"
Author
Jiakai Lian, [email protected]
License
JKLThreadSafeOperator is available under the MIT license. See the LICENSE file for more info.
Latest podspec
{ "name": "JKLThreadSafeOperator", "version": "0.1.0", "summary": "A light-weight thread-safe operation wrapper used to perform sync read, aync barrier write on a concurrent queue.", "description": "Make a class thread-safe could be painful, as involving wrapping all your public methods into GCD operations. nnThis operator is designated to perform thread-safe operations by simply wrapping read & write operations into corresponding blocks. So without changing original model classes, the project could benefit from multi-threading without compromising the stability.n", "homepage": "https://github.com/jiakai-lian/JKLThreadSafeOperator", "license": "MIT", "authors": { "Jiakai Lian": "[email protected]" }, "source": { "git": "https://github.com/jiakai-lian/JKLThreadSafeOperator.git", "tag": "0.1.0" }, "platforms": { "ios": "7.0" }, "requires_arc": true, "source_files": "Pod/Classes/**/*", "resource_bundles": { "JKLThreadSafeOperator": [ "Pod/Assets/*.png" ] } }
Sun, 06 Mar 2016 10:54:03 +0000