Jon Herron 7c219fd731 Squashed 'SpiffWorkflow/' content from commit 63db3e4
git-subtree-dir: SpiffWorkflow
git-subtree-split: 63db3e45947ec66b8d0efc2c74064004f8ff482c
2022-10-12 10:19:53 -04:00

31 lines
593 B
Python

from builtins import object
try:
# python 2
from mutex import mutex
except ImportError:
# python 3
from threading import Lock
class mutex(object):
def __init__(self):
self.lock = Lock()
def lock(self):
raise NotImplementedError
def test(self):
has = self.lock.acquire(blocking=False)
if has:
self.lock.release()
return has
def testandset(self):
return self.lock.acquire(blocking=False)
def unlock(self):
self.lock.release()