Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use built-in callback cancellation from later #115

Merged
merged 2 commits into from
Dec 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Depends:
Imports:
DBI,
R6,
later
later (>= 1.0.0)
Suggests:
testthat,
tibble,
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
pool 0.1.5.9000
================

* Fixed #114: `dbPool()` objects previously could leak memory. (#115)

pool 0.1.5
================

Expand Down
7 changes: 2 additions & 5 deletions R/scheduler.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ NULL
## Used in the Pool class to schedule and cancel tasks (based on `later`)
scheduleTask <- function(func, delay) {
force(func)
later::later(function() {
cancel <- later::later(function() {
# Make sure warn is at least 1 so that warnings are emitted immediately.
# (warn=2 is also OK, for use in debugging.)
warn_level <- getOption("warn")
Expand All @@ -21,10 +21,7 @@ scheduleTask <- function(func, delay) {
## > cancel <- scheduleTaskRecurring(function() print("hello"), 1)
## [1] "hello"
## [1] "hello"
## > cancel()
function() {
func <<- NULL
}
cancel
}

## Used in the Pool class. This function builds on top of `scheduleTask`
Expand Down