This repository has been archived on 2025-04-11. You can view files and clone it, but cannot push or open issues or pull requests.
uwu-me/uwume/lib/classUwuCounter.py

21 lines
No EOL
548 B
Python

#!/bin/python
from threading import Lock
class UwuCounter:
'''
Class defined to be a threadsafe Atomic Counter for UwUs.
Original concept and code for this idea was borrowed from
a GitHub Gist by user benhoyt
https://gist.github.com/benhoyt/8c8a8d62debe8e5aa5340373f9c509c7
'''
def __init__(self, initial=0):
super().__init__()
self.curval = initial
self._lock = Lock()
def increment(self, num=1):
with self._lock:
self.curval += num
return self.curval