diff options
author | Elliott Hughes <enh@google.com> | 2021-06-24 14:34:13 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2021-06-24 14:35:24 -0700 |
commit | 8afb6adb7510773c96435470a6bd3ef2632ccd27 (patch) | |
tree | 2e094b154708b0f59aed5e70dee000b9f765d7bb /lib/python2.7/mutex.py | |
parent | 96d94994f490d4eee9ca54f65733fa43741b232f (diff) | |
download | linux-x86-master.tar.gz |
Remove Linux gdb.HEADandroid-t-preview-2android-t-preview-1android-t-beta-3android-s-v2-preview-2android-s-v2-preview-1android-s-v2-beta-3android-s-v2-beta-2android-s-qpr3-beta-1android-s-beta-5android-s-beta-4android-s-beta-3mastermainandroid-t-preview-1android-s-v2-preview-1android-s-v2-beta-3android-s-qpr3-beta-1android-s-beta-5android-s-beta-4
gdb's no longer supported: use lldb instead (or "bring your own" gdb if
you really need it, such as for kernel use).
Test: treehugger
Change-Id: Ia0ce61aff68dd19a9e453ab3272e9f46bc9b5e84
Diffstat (limited to 'lib/python2.7/mutex.py')
-rw-r--r-- | lib/python2.7/mutex.py | 55 |
1 files changed, 0 insertions, 55 deletions
diff --git a/lib/python2.7/mutex.py b/lib/python2.7/mutex.py deleted file mode 100644 index f8acba4..0000000 --- a/lib/python2.7/mutex.py +++ /dev/null @@ -1,55 +0,0 @@ -"""Mutual exclusion -- for use with module sched - -A mutex has two pieces of state -- a 'locked' bit and a queue. -When the mutex is not locked, the queue is empty. -Otherwise, the queue contains 0 or more (function, argument) pairs -representing functions (or methods) waiting to acquire the lock. -When the mutex is unlocked while the queue is not empty, -the first queue entry is removed and its function(argument) pair called, -implying it now has the lock. - -Of course, no multi-threading is implied -- hence the funny interface -for lock, where a function is called once the lock is aquired. -""" -from warnings import warnpy3k -warnpy3k("the mutex module has been removed in Python 3.0", stacklevel=2) -del warnpy3k - -from collections import deque - -class mutex: - def __init__(self): - """Create a new mutex -- initially unlocked.""" - self.locked = False - self.queue = deque() - - def test(self): - """Test the locked bit of the mutex.""" - return self.locked - - def testandset(self): - """Atomic test-and-set -- grab the lock if it is not set, - return True if it succeeded.""" - if not self.locked: - self.locked = True - return True - else: - return False - - def lock(self, function, argument): - """Lock a mutex, call the function with supplied argument - when it is acquired. If the mutex is already locked, place - function and argument in the queue.""" - if self.testandset(): - function(argument) - else: - self.queue.append((function, argument)) - - def unlock(self): - """Unlock a mutex. If the queue is not empty, call the next - function with its argument.""" - if self.queue: - function, argument = self.queue.popleft() - function(argument) - else: - self.locked = False |