15 lines
338 B
Python
15 lines
338 B
Python
from multiprocessing import Semaphore
|
|
|
|
creatingID = Semaphore()
|
|
|
|
class Identifiable:
|
|
lastID: int = 0
|
|
|
|
def __init__(self):
|
|
creatingID.acquire()
|
|
self.lastID += 1
|
|
self.id = self.lastID
|
|
creatingID.release()
|
|
|
|
def __eq__(self, other):
|
|
return self.id == other.id and type(self) == type(other)
|