Initialize a new atomic counter to given initial value
(self, initial=0)
| 4 | class AtomicCounter: |
| 5 | """An atomic, thread-safe counter""" |
| 6 | def __init__(self, initial=0): |
| 7 | """Initialize a new atomic counter to given initial value""" |
| 8 | self._value = initial |
| 9 | self._lock = threading.Lock() |
| 10 | |
| 11 | def inc(self, num=1): |
| 12 | """Atomically increment the counter by num and return the new value""" |
nothing calls this directly
no outgoing calls
no test coverage detected