forked from Quick/Nimble
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Quick#224 from jeffh/stable-async
Stabilize Asynchronous Expectations
- Loading branch information
Showing
15 changed files
with
661 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import Foundation | ||
|
||
/// "Global" state of Nimble is stored here. Only DSL functions should access / be aware of this | ||
/// class' existance | ||
internal class NimbleEnvironment { | ||
static var activeInstance: NimbleEnvironment { | ||
get { | ||
let env = NSThread.currentThread().threadDictionary["NimbleEnvironment"] | ||
if let env = env as? NimbleEnvironment { | ||
return env | ||
} else { | ||
let newEnv = NimbleEnvironment() | ||
self.activeInstance = newEnv | ||
return newEnv | ||
} | ||
} | ||
set { | ||
NSThread.currentThread().threadDictionary["NimbleEnvironment"] = newValue | ||
} | ||
} | ||
|
||
// TODO: eventually migrate the global to this environment value | ||
var assertionHandler: AssertionHandler { | ||
get { return NimbleAssertionHandler } | ||
set { NimbleAssertionHandler = newValue } | ||
} | ||
var awaiter: Awaiter | ||
|
||
init() { | ||
awaiter = Awaiter( | ||
waitLock: AssertionWaitLock(), | ||
asyncQueue: dispatch_get_main_queue(), | ||
timeoutQueue: dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.