Skip to content

Commit

Permalink
Try to address #414
Browse files Browse the repository at this point in the history
If we're only assigning to idle workers,
we need to wait to pop messages until
after the target is built
  • Loading branch information
wlandau-lilly committed Jun 13, 2018
1 parent b81f0a0 commit fea4acb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion R/mclapply.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ mc_worker <- function(worker, config){
ready_queue <- mc_get_ready_queue(worker, config)
done_queue <- mc_get_done_queue(worker, config)
while (TRUE){
while (nrow(msg <- ready_queue$pop()) < 1){
while (nrow(msg <- ready_queue$list(1)) < 1){
Sys.sleep(mc_wait)
}
if (identical(msg$message, "done")){
ready_queue$pop(1)
return()
}
target <- msg$title
Expand All @@ -85,6 +86,7 @@ mc_worker <- function(worker, config){
downstream = config$cache$list(namespace = "mc_protect"),
flag_attempt = TRUE
)
ready_queue$pop(1)
done_queue$push(title = target, message = "target")
}
}
Expand Down

0 comments on commit fea4acb

Please sign in to comment.