Class: Gameworks::Servlet::MatchMaker::Promise
- Inherits:
-
Object
- Object
- Gameworks::Servlet::MatchMaker::Promise
- Defined in:
- lib/gameworks/servlet/match_maker.rb
Instance Method Summary collapse
- #demand ⇒ Object
- #fulfill(value) ⇒ Object
-
#initialize ⇒ Promise
constructor
A new instance of Promise.
Constructor Details
#initialize ⇒ Promise
Returns a new instance of Promise.
7 8 9 |
# File 'lib/gameworks/servlet/match_maker.rb', line 7 def initialize @em_queue = EventMachine::Queue.new end |
Instance Method Details
#demand ⇒ Object
11 12 13 |
# File 'lib/gameworks/servlet/match_maker.rb', line 11 def demand @em_queue.pop{ |value| yield value } end |
#fulfill(value) ⇒ Object
15 16 17 |
# File 'lib/gameworks/servlet/match_maker.rb', line 15 def fulfill(value) @em_queue.push(value) end |