On Mon, 2008-02-11 at 00:58 +0100, Jason Tackaberry wrote:
> MainThreadCallback.set_async is deprecated (and logs a warning).  Calling a
> MainThreadCallback will now return an InProgress object, and the caller
> can wait() on this InProgress if synchronous behaviour is needed.

I should have mentioned that although this is the new and better way,
the API should be backward compatible.  If set_async(False) is set, the
result is always returned (regardless if it's called in the main thread
or not).

The new approach also fixes the problem if a MainThreadCallback is
invoked in two threads at the same time.  With the old way, there is a
single lock and result/exception holder for MainThreadCallback so if it
is called at the same time in two threads, you will get unpredictable
results.  (dischi, you noted this bug in a comment, which has been
removed since the bug is fixed if you use cb().wait().)

The new way solves this by creating a unique InProgress for each
invocation, and relying on the new thread-safe semantics added to
InProgress.wait().  It uses a threading.Event object, so even if the
InProgress is finished before the other thread wait()s on it, it will
still work as expected.

Jason.


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freevo-devel mailing list
Freevo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to