55from ._sync import sync_performer
66
77
8- class ERef (object ):
8+ class Reference (object ):
99 """
1010 An effectful mutable variable, suitable for sharing between multiple
1111 logical threads of execution, that can be read and modified in a purely
@@ -19,44 +19,47 @@ def __init__(self, initial):
1919
2020 def read (self ):
2121 """Return an Effect that results in the current value."""
22- return Effect (ReadERef ( eref = self ))
22+ return Effect (ReadReference ( ref = self ))
2323
2424 def modify (self , transformer ):
2525 """
2626 Return an Effect that updates the value with ``fn(old_value)``.
2727 """
28- return Effect (ModifyERef ( eref = self , transformer = transformer ))
28+ return Effect (ModifyReference ( ref = self , transformer = transformer ))
2929
3030
31- @attributes (['eref ' ])
32- class ReadERef (object ):
33- """Intent that gets an ERef value."""
31+ @attributes (['ref ' ])
32+ class ReadReference (object ):
33+ """Intent that gets a Reference's current value."""
3434
3535
36- @attributes (['eref' , 'transformer' ])
37- class ModifyERef (object ):
38- """Intent that modifies an ERef value in-place with a transformer func."""
36+ @attributes (['ref' , 'transformer' ])
37+ class ModifyReference (object ):
38+ """
39+ Intent that modifies a Reference value in-place with a transformer func.
40+ """
3941
4042
4143@sync_performer
42- def perform_read_eref (dispatcher , intent ):
43- """Performer for :obj:`ReadERef `."""
44- return intent .eref ._value
44+ def perform_read_reference (dispatcher , intent ):
45+ """Performer for :obj:`ReadReference `."""
46+ return intent .ref ._value
4547
4648
4749@sync_performer
48- def perform_modify_eref (dispatcher , intent ):
50+ def perform_modify_reference (dispatcher , intent ):
4951 """
50- Performer for :obj:`ModifyERef `.
52+ Performer for :obj:`ModifyReference `.
5153
52- Note that while :obj:`ModifyERef ` is designed to allow strong consistency,
53- this performer is _not_ threadsafe, in the sense that it's possible to
54- overwrite unobserved values. This may change in the future.
54+ Note that while :obj:`ModifyReference ` is designed to allow strong
55+ consistency, this performer is _not_ threadsafe, in the sense that it's
56+ possible to overwrite unobserved values. This may change in the future.
5557 """
56- new_value = intent .transformer (intent .eref ._value )
57- intent .eref ._value = new_value
58+ new_value = intent .transformer (intent .ref ._value )
59+ intent .ref ._value = new_value
5860 return new_value
5961
6062
61- eref_dispatcher = TypeDispatcher ({ReadERef : perform_read_eref ,
62- ModifyERef : perform_modify_eref })
63+ reference_dispatcher = TypeDispatcher ({
64+ ReadReference : perform_read_reference ,
65+ ModifyReference : perform_modify_reference })
0 commit comments