Jason Tackaberry wrote: > On Sat, 2008-03-01 at 10:51 +0100, Dirk Meyer wrote: >> +def synchronized(lock=threading.Lock()): > > With this, all functions decorated with synchronized will use the same > lock. > > @synchronized() > def foo(): ... > > @synchronized() > def bar(): ... > > Ideally this code should allow foo() and bar() to execute in parallel, > but it doesn't. Sure you could create a separate mutex for foo() and > pass it to its synchronized() decorator, but that sucks.
What do you suggest? The best solution would be a synchronized function similar to the one in Java. You can use every object as lock (which would mean to add __kaa_lock to each object. And the same function should also be used in blocks, maybe with could help. Pseudo code class Foo(object): @synchronized() def f1(self): critical def f2(self): uncritical with synchronized(self): critical uncritical That would be a hack to use the same function as decorator and inside a function, but it would be a very cool feature. > Also, I think threading.RLock() should be used, to allow reentrancy in > the same thread. OK Dischi -- "The question of whether a computer can think is no more interesting than the question of whether a submarine can swim." [Edsger Dijkstra]
pgprmZnfRVzTs.pgp
Description: PGP signature
------------------------------------------------------------------------- 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