Selfie
Loading...
Searching...
No Matches
selfie_lib.WriteTracker.WriteTracker Class Reference
Inheritance diagram for selfie_lib.WriteTracker.WriteTracker:
selfie_lib.WriteTracker.DiskWriteTracker selfie_lib.WriteTracker.InlineWriteTracker selfie_lib.WriteTracker.ToBeFileWriteTracker

Public Member Functions

 __init__ (self)
 
 recordInternal (self, T key, U snapshot, CallStack call, SnapshotFileLayout layout, bool allow_multiple_equivalent_writes=True)
 

Public Attributes

 lock
 

Detailed Description

Definition at line 135 of file WriteTracker.py.

Constructor & Destructor Documentation

◆ __init__()

selfie_lib.WriteTracker.WriteTracker.__init__ (   self)

Reimplemented in selfie_lib.WriteTracker.ToBeFileWriteTracker.

Definition at line 136 of file WriteTracker.py.

136 def __init__(self):
137 self.lock = threading.Lock()
138 self.writes: dict[T, FirstWrite[U]] = {}
139

Member Function Documentation

◆ recordInternal()

selfie_lib.WriteTracker.WriteTracker.recordInternal (   self,
T  key,
U  snapshot,
CallStack  call,
SnapshotFileLayout  layout,
bool   allow_multiple_equivalent_writes = True 
)

Definition at line 140 of file WriteTracker.py.

147 ):
148 with self.lock:
149 this_write = FirstWrite(snapshot, call)
150 if key not in self.writes:
151 self.writes[key] = this_write
152 return
153
154 existing = self.writes[key]
155 if existing.snapshot != snapshot:
156 raise ValueError(
157 f"Snapshot was set to multiple values!\n first time: {existing.call_stack.location.ide_link(layout)}\n this time: {call.location.ide_link(layout)}"
158 )
159 elif not allow_multiple_equivalent_writes:
160 raise ValueError("Snapshot was set to the same value multiple times.")
161
162

Member Data Documentation

◆ lock

selfie_lib.WriteTracker.WriteTracker.lock

Definition at line 137 of file WriteTracker.py.


The documentation for this class was generated from the following file: