2017-01-27 09:10:27 -04:00
|
|
|
updated="update_ack"
|
2017-01-27 13:21:09 -04:00
|
|
|
update_no=0
|
2017-01-27 09:10:27 -04:00
|
|
|
function init(){
|
|
|
|
barrier = stigmergy.create(101)
|
|
|
|
barrier.put(id,1)
|
|
|
|
barrier_val=0
|
|
|
|
barrier.onconflict(function (k,l,r) {
|
|
|
|
if(r. data < l. data or (r. data == l. data )) return l
|
|
|
|
else return r
|
|
|
|
})
|
|
|
|
|
2017-05-11 23:12:59 -03:00
|
|
|
s = swarm.create(1)
|
|
|
|
s.join()
|
2017-01-27 09:10:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function stand_by(){
|
|
|
|
|
|
|
|
barrier.get(id)
|
|
|
|
barrier_val = barrier.size()
|
|
|
|
|
|
|
|
neighbors.listen(updated,
|
|
|
|
function(vid, value, rid) {
|
2017-01-27 13:38:20 -04:00
|
|
|
print(" got from",vid," ", " value = ",value," ","rid"," " )
|
2017-05-18 00:03:42 -03:00
|
|
|
if(value==update_no) barrier.put(rid,1)
|
2017-01-27 09:10:27 -04:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function step() {
|
|
|
|
|
|
|
|
stand_by()
|
|
|
|
|
|
|
|
}
|