Class: Wassup::Helpers::GitHub::RequestFuture
- Inherits:
-
Object
- Object
- Wassup::Helpers::GitHub::RequestFuture
- Defined in:
- lib/wassup/helpers/github_rate_limiter.rb
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize ⇒ RequestFuture
constructor
A new instance of RequestFuture.
- #set_error(error) ⇒ Object
- #set_result(result) ⇒ Object
Constructor Details
#initialize ⇒ RequestFuture
Returns a new instance of RequestFuture.
346 347 348 349 350 351 352 |
# File 'lib/wassup/helpers/github_rate_limiter.rb', line 346 def initialize @mutex = Mutex.new @condition = ConditionVariable.new @result = nil @error = nil @completed = false end |
Instance Method Details
#get ⇒ Object
370 371 372 373 374 375 376 |
# File 'lib/wassup/helpers/github_rate_limiter.rb', line 370 def get @mutex.synchronize do @condition.wait(@mutex) until @completed raise @error if @error @result end end |
#set_error(error) ⇒ Object
362 363 364 365 366 367 368 |
# File 'lib/wassup/helpers/github_rate_limiter.rb', line 362 def set_error(error) @mutex.synchronize do @error = error @completed = true @condition.signal end end |
#set_result(result) ⇒ Object
354 355 356 357 358 359 360 |
# File 'lib/wassup/helpers/github_rate_limiter.rb', line 354 def set_result(result) @mutex.synchronize do @result = result @completed = true @condition.signal end end |