Skip to content

Commit

Permalink
Merge pull request #115 from rstudio/fix-leak
Browse files Browse the repository at this point in the history
Use built-in callback cancellation from later
  • Loading branch information
jcheng5 committed Dec 11, 2020
2 parents b8a29b0 + f8f9ef8 commit 0d059e4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
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

0 comments on commit 0d059e4

Please sign in to comment.