Merge pull request #87 from TouchInstinct/fix/synchronization

Fix. Synchronization
This commit is contained in:
Igor Kislyuk 2017-09-26 15:35:55 +03:00 committed by GitHub
commit 6274a4e568
3 changed files with 13 additions and 2 deletions

View File

@ -6,4 +6,8 @@
## 0.5.7
- **Add**: String extension `localizedComponent(value:stringOne:stringTwo:stringMany:)`
- **Add**: String extension `localizedComponent(value:stringOne:stringTwo:stringMany:)`
## 0.5.8
- **Fix**: Synchronization over `NSRecursiveLock` for request count tracker in NetworkService

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "LeadKit"
s.version = "0.5.7"
s.version = "0.5.8"
s.summary = "iOS framework with a bunch of tools for rapid development"
s.homepage = "https://github.com/TouchInstinct/LeadKit"
s.license = "Apache License, Version 2.0"

View File

@ -30,6 +30,9 @@ import RxAlamofire
/// Has an ability to automatically show / hide network activity indicator
open class NetworkService {
/// Enable synchronization for setting variable from different thread
private let lock = NSRecursiveLock()
private let requestCountVariable = Variable<Int>(0)
public let sessionManager: Alamofire.SessionManager
@ -68,11 +71,15 @@ open class NetworkService {
}
fileprivate func increaseRequestCounter() {
lock.lock()
requestCountVariable.value += 1
lock.unlock()
}
fileprivate func decreaseRequestCounter() {
lock.lock()
requestCountVariable.value -= 1
lock.unlock()
}
}