actors :: MeetingPlace :: defaultinit
class MeetingPlace
var meetings_left: Int
var firstcolor: nullable Int
var firstid: Int = 0
var current: Future[Pair] is noinit
private var mutex = new Mutex
fun meet(id, c: Int): nullable Pair do
var new_pair = new Future[Pair]
mutex.lock
if meetings_left == 0 then
mutex.unlock
return null
else
if firstcolor == null then
firstcolor = c
firstid = id
current = new Future[Pair]
else
var color = complements[c][firstcolor.as(not null)]
current.set_value(new Pair(id == firstid, color))
firstcolor = null
meetings_left -= 1
end
new_pair = current
end
mutex.unlock
return new_pair.join
end
end
lib/actors/examples/chameneos-redux/chameneosredux.nit:50,1--80,3