Class: Gameworks::Servlet::MatchMaker::Promise

Inherits:
Object
  • Object
show all
Defined in:
lib/gameworks/servlet/match_maker.rb

Instance Method Summary collapse

Constructor Details

#initializePromise

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

#demandObject



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