class SharedLock(object):
Implements a shared lock.
Multiple threads can acquire the lock in a shared way by calling acquire(shared=1). In order to acquire the lock in an exclusive way threads can call acquire(shared=0).
Notes on data structures: __pending contains a priority queue (heapq) of all pending acquires: [(priority1: prioqueue1), (priority2: prioqueue2), ...]. Each per-priority queue contains a normal in-order list of conditions to be notified when the lock can be acquired. Shared locks are grouped together by priority and the condition for them is stored in __pending_shared if it already exists. __pending_by_prio keeps references for the per-priority queues indexed by priority for faster access.
Method | __init__ |
Construct a new SharedLock. |
Method | __repr__ |
Undocumented |
Method | acquire |
Acquire a shared lock. |
Method | delete |
Delete a Shared Lock. |
Method | downgrade |
Changes the lock mode from exclusive to shared. |
Method |
|
Retrieves information for querying locks. |
Method | is |
Is the current thread somehow owning the lock at this time? |
Method | release |
Release a Shared Lock. |
Class Variable | __slots__ |
Undocumented |
Instance Variable | name |
the name of the lock |
Method | __acquire |
Acquire a shared lock. |
Method | __can |
Determine whether lock can be acquired. |
Method | __check |
Raises an exception if the lock has been deleted. |
Method | __do |
Actually acquire the lock. |
Method | __find |
Tries to find the topmost queued entry with pending acquires. |
Method | __is |
Is the current thread holding the lock exclusively at this time? |
Method | __is |
Checks whether the passed condition is on top of the queue. |
Method | __is |
Is the current thread somehow owning the lock at this time? |
Method | __is |
Is the current thread sharing the lock at this time? |
Method | __notify |
Notifies topmost condition in queue of pending acquires. |
Method | _acquire |
Undocumented |
Method | _check |
Checks whether there are any pending acquires. |
Method | _count |
Returns the number of pending acquires. |
Method | _notify |
Exported version of __notify_topmost . |
Method | _release |
Undocumented |
Instance Variable | __deleted |
Undocumented |
Instance Variable | __exc |
Undocumented |
Instance Variable | __lock |
Undocumented |
Instance Variable | __pending |
Undocumented |
Instance Variable | __pending |
Undocumented |
Instance Variable | __pending |
Undocumented |
Instance Variable | __shr |
Undocumented |
Instance Variable | __time |
Undocumented |
Construct a new SharedLock.
Parameters | |
name | the name of the lock |
monitor | Lock monitor with which to register |
_time | Undocumented |
Acquire a shared lock.
Parameters | |
shared:integer (0/1) used as a boolean | whether to acquire in shared mode; by default an exclusive lock will be acquired |
timeout:float | maximum waiting time before giving up |
priority:integer | Priority for acquiring lock |
test | Special callback function for unittesting |
Delete a Shared Lock.
This operation will declare the lock for removal. First the lock will be acquired in exclusive mode if you don't already own it, then the lock will be put in a state where any future and pending acquire() fail.
Parameters | |
timeout:float | maximum waiting time before giving up |
priority:integer | Priority for acquiring lock |
Changes the lock mode from exclusive to shared.
Pending acquires in shared mode on the same priority will go ahead.
Retrieves information for querying locks.
Parameters | |
requested:set | Requested information, see query.LQ_* |
Is the current thread somehow owning the lock at this time?
Parameters | |
shared |
|
Release a Shared Lock.
You must have acquired the lock, either in shared or in exclusive mode, before calling this function.
Acquire a shared lock.
Parameters | |
shared | whether to acquire in shared mode; by default an exclusive lock will be acquired |
timeout | maximum waiting time before giving up |
priority:integer | Priority for acquiring lock |
Tries to find the topmost queued entry with pending acquires.
Removes empty entries while going through the list.
Checks whether the passed condition is on top of the queue.
The caller must make sure the queue isn't empty.