Re: var watcher behaviour
[email protected] (Joshua N Pritikin)
| Newsgroups | perl.loop |
|---|---|
| Message-ID | <[email protected]> |
On Tue, Feb 08, 2000 at 02:42:48PM +0100, [email protected] wrote: > Hm, it seems now clearer to me and to be no error: my modifying timer did > this: > > - it incremented the variable by the ++ operator: one read, one write: 2 > accesses; > - it compared the variable with a number: 1 read access. > > So there were three access events (poll was set to "rw"). Ok, one has to be > very carefully here. Oh, yah. > (Or to temporarily disable the associated watcher - but > how can I get all the watchers watching a certain variable? parked=>1? > And what if it is modified in code I cannot control?) > Of course, fine granularity SHOULD be > available. So, hm ... I remember an optional "clumb" feature. What are you > thinking? I got rid of clump (except for signals). Why do you need it for var watchers? > By the way, the sent script activated the var watcher four times, not only > three - what was the fourth event? Well, that took some research. Event->timer(interval=>1, repeat=>1, cb=>sub { my $nr=int(rand(MAX))+1; no strict 'refs'; warn "---> CHANGED var $nr (new value is ", ++${"var$nr"}, ").\n"; ^read-inc-^write ^join $_[0]->w->cancel if ${"var$nr"}>5; ^read }); The implicit join does another read of the variable. -- "Never ascribe to malice that which can be explained by stupidity." via, but not speaking for Deutsche Bank