maffoo/pylabrad — pull request #3 by martinisgroup (2013-10-04 00:08:32+00:00)
Title: Future.wait() now processes callbacks on any ready Future

Previously Future.wait() would wait for its own thread safe Event to be set in the networking thread before invoking callbacks. This is not optimal for the case that we have several pending Futures. For example imagine we have to pending Futures

futureA = Future()
futureB = Future()

futures = [futureA, futureB]
...and we add some callbacks...

If we choose wait for their results like this

results = [f.wait() for f in futures]

then we will wait on futureA, process it's callbacks, and _then_ wait on futureB. If futureB becomes ready before futureA then we are wasting time. This pull request would bring in an updated Future class that replaces the thread safe Events with a Queue from which we grab _any_ available Future when we wait. If the one we get is the one on which we called .wait() then we return the result.