Kristján Valur Jónsson added the comment:

I admit that I kind of like Java's approach to this.  First off, they define an 
interface, ReadWriteLock:
http://docs.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/locks/ReadWriteLock.html
There, they also discuss the different choices an implementation of the 
interface can make, regarding a) policy, b) reentrancy, c) upgrading or 
downgrading.
A concrete implemention is then presented in the form of the 
ReentrantReadWriteLock, with documented behaviour for the above.
The rest of threading is also, as previously pointed out, more or less a 
rip-off from Java.

Since there is no single "correct" choice for the above, and since the 
implementation restrictions are different between inter-process and 
inter-thread locks, it would make sense to adopt a similar model, where a 
RWLock() function is a factory function, taking an argument specify a desired 
class of locks.

The policies that have been seen in this thread are:
a) greedy policy (no policy)
b) writer preference
c) 'Fair' (or in-order) preference.
All have their benefits and disadvantages.

We have also seen "recursive" and "nonrecursive".

The restrictions appear more serious in the inter-process case since I don't 
know if it is possible to maintain a shared dynamic array of thread ids across 
processes.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8800>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to