What happens when a defer-generated cb() is called back one than once? #11

Closed
maxtaco opened this Issue Feb 2, 2012 · 2 comments

Projects

None yet

2 participants

@maxtaco
Owner

Should maybe make it impotent after the first call, and or have the Deferrals object complain if its counter drops below 0.

@craigyk

Are you trying to figure out how to handle callbacks that are passed for things like progress updates (so they're legitimately called more than once)? Or are there circumstances where the iced implementation might be buggy and you want to catch them?

@maxtaco
Owner

I was worried about this case:

loop
  await fs.watchFile "/path/to/some/changing/file.txt", {}, defer curr, prev
  console.log "it changed!"

This is an issue because fs.watchFile will call back repeatedly, every time the file is changed (unless you give { persistent : 0} as options). You'll wind up with n^2 log lines, for n changes. Probably not what you wanted.... In this case, I would say just use hand-rolled cbs, but the iced runtime should warn you.

@maxtaco maxtaco added a commit that closed this issue Feb 22, 2012
@maxtaco This closes #11. Add extra warnings and seat-belts when awaits and
defers are being abused, like with mutliple calls per deferral, or a
reentry to a dead await block.  We still want to allo multi-use of a
deferral, and do that in the case of a Rendezvous with the id(1,true)
feature.
9ada545
@maxtaco maxtaco closed this in 9ada545 Feb 22, 2012
@maxtaco maxtaco added a commit that referenced this issue Sep 19, 2012
@maxtaco This closes #11. Add extra warnings and seat-belts when awaits and
defers are being abused, like with mutliple calls per deferral, or a
reentry to a dead await block.  We still want to allo multi-use of a
deferral, and do that in the case of a Rendezvous with the id(1,true)
feature.
dfa01a7
@maxtaco maxtaco added a commit that referenced this issue Dec 5, 2012
@maxtaco This closes #11. Add extra warnings and seat-belts when awaits and
defers are being abused, like with mutliple calls per deferral, or a
reentry to a dead await block.  We still want to allo multi-use of a
deferral, and do that in the case of a Rendezvous with the id(1,true)
feature.
040674e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment