mirror of
https://github.com/iperov/DeepFaceLive.git
synced 2024-12-25 07:21:13 -08:00
23 lines
539 B
Python
23 lines
539 B
Python
import threading
|
|
|
|
class AtomicInteger:
|
|
def __init__(self, value=0):
|
|
self._value = int(value)
|
|
self._lock = threading.Lock()
|
|
|
|
def inc(self, d = 1):
|
|
with self._lock:
|
|
self._value += int(d)
|
|
return self._value
|
|
|
|
def dec(self, d = 1):
|
|
return self.inc(-d)
|
|
|
|
def get_value(self) -> int:
|
|
with self._lock:
|
|
return self._value
|
|
|
|
def set_value(self, v : int):
|
|
with self._lock:
|
|
self._value = int(v)
|
|
return self._value |