Merge pull request #87 from TouchInstinct/fix/synchronization
Fix. Synchronization
This commit is contained in:
commit
6274a4e568
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue