rstudio / promises

A promise library for R
https://rstudio.github.io/promises
Other
197 stars 19 forks source link

Add `WorkQueue#unschedule_work` or similar #95

Open king-of-poppk opened 11 months ago

king-of-poppk commented 11 months ago

Would it be possible to add a method to the WorkQueue class that allows to remove a callback from the queue? This probably means changing the return value of schedule_work to some sort of handle if you want to properly reference callbacks that have been queued more than once.

Note that identical cannot be used to search through the queue:

> f <- \() 1
> g <- \() 1
> identical(f, g)
[1] TRUE

PS: Although maybe using ignore.srcref = FALSE is sufficient:

> identical(f, g, ignore.srcref = FALSE)
[1] FALSE
> identical(f, f, ignore.srcref = FALSE)
[1] TRUE
> identical(g, g, ignore.srcref = FALSE)
[1] TRUE