negativecode/vines-agent — pull request #1 by mudasobwa (2012-11-25 13:53:53+00:00)
Title: Get rid of Fibers in honour of EventMachine since it’s already reached version 1 milestone

— Introduced mutex on “register_handle” to prevent double-registering; the former solution with a variable “@ready” was not sufficient due to possible context switch inside “unless ready” block;
— Got rid of Fibers in honour of EventMachine, using mapped nested Iterators in the following manner:
```ruby
@stream.write_with_handler(disco) do |result|
…
# iterate thru disco results and wait until all collected
EM::Iterator.new(result.items).map proc{ |c, it_disco|
…
@stream.write_with_handler(info) do |reply|
…
# iterate thru discoinfo results and wait until all collected,
# then switch the parent’s iterator
EM::Iterator.new(reply.features).map proc{ |f, it_info|
it_info.return …
}, proc{ |comps|
# one more disco item was utilized
it_disco.return …
}
…
end
…
}, proc{ |compss|
# yielding
…
}
end
```
— Introduced “@components” variable to collect components, if there are many returned by discovery. This is done ‘de bene esse’ and used currently to log warning of a kind “Hey, we use the first instance of components out of N available”