Source code for rwlock.serviceparts

"""
Module **rwlock.serviceparts** has a class ``ServiceParts``, which has
a separate function for each component of each pseudo-Python function 
in the abstract service program.
"""

# threading.get_ident() returns the id of the calling thread
from threading import get_ident

[docs]class ServiceParts(): """ Anatomy of *pseudo-Python* class ``rwlock.service.Service``. Has the same variables: ``rset`` and ``wset``. For each non-init function ``f`` in the pseudo-Python class, has four functions: ``f_CIC``, ``f_CU``, ``f_ROC`` and ``f_RU``. """ def __init__(self): self.rset = set() self.wset = set() ### acqr(self) components ######################################## def acqr_CIC(self): return get_ident() not in self.rset.union(self.wset) def acqr_CU(self): pass def acqr_ROC(self): return self.wset == set() def acqr_RU(self): self.rset.add(get_ident()) ### relr(self) components ######################################## def relr_CIC(self): return get_ident() in self.rset def relr_CU(self): self.rset.remove(get_ident()) def relr_ROC(self): return True def relr_RU(self): pass ### acqw(self) components ######################################## def acqw_CIC(self): return get_ident() not in self.rset.union(self.wset) def acqw_CU(self): pass def acqw_ROC(self): return self.wset == self.rset == set() def acqw_RU(self): self.wset.add(get_ident()) ### relw(self) components ######################################## def relw_CIC(self): return get_ident() in self.wset def relw_CU(self): self.wset.remove(get_ident()) def relw_ROC(self): return True def relw_RU(self): pass
if __name__ == '__main__': serviceparts = ServiceParts() print('rwlock.serviceparts.ServiceParts instantiated successfully', flush=True)