[PEAK] Re: trellis.Set.discard
Sergey Schetinin
maluke at gmail.com
Sat Oct 11 17:04:45 EDT 2008
After a lot of experimenting, this code seems to provide something useful info:
from pprint import pprint as pp
class CV(Component):
v = attr(False)
s = make(Set)
@maintain
def maintain(self):
#print 'in maintain'
if self.v:
act = 'add'
self.s.add(1)
else:
act = 'discard'
self.s.discard(1)
#task.s.remove(1)
@on_undo
def undo(): print "UNDO", act
@perform
def perform(self):
print '-'*20, self.v, self.s
def doit():
cv = CV()
print 'undo history:'
pp(ctrl.undo)
cv.v = True
print 'TASK'
@atomically
def naked():
#cell = trellis.Value()
cell = trellis.Cell(lambda: None)
ctrl.current_listener = cell
doit()
#pp(ctrl.writes)
ctrl._process_writes(cell)
ctrl.current_listener = None
print
print 'ATOMICALLY'
atomically(doit)
It shows two differences, first is that maintain rule is not rolled
back at all for @atomically, maintain just runs twice, which is
strange.
Second is that inside doit() the undo histrory for @atomically has two
more items, but this doesn't matter, because they never run.
So the question is why undo isn't triggered for normal atomic call,
but it is for task-style invoke?
More information about the PEAK
mailing list