Skip to content

Commit b844355

Browse files
more on event handling via conditions
1 parent 9a60db1 commit b844355

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: future.p2p
22
Title: A Peer-to-Peer Compute Cluster via Futureverse
3-
Version: 0.3.0-9012
3+
Version: 0.3.0-9013
44
Description: Implementation of the 'Future' API <doi:10.32614/RJ-2021-048> that resolves futures on a peer-to-peer ('P2P') compute environment. By using this future backend, you and your friends can share your spare compute resources with each other.
55
Imports:
66
future (>= 1.67.0),

R/worker.R

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -236,14 +236,6 @@ worker <- function(cluster = p2p_cluster_name(), host = "pipe.pico.sh", ssh_args
236236
Sys.sleep(0.1)
237237
next
238238
}
239-
240-
if ("interrupted" %in% info) {
241-
state <- "waiting"
242-
future <- NULL
243-
client <- NULL
244-
## FIXME: Update client via P2P message board
245-
break
246-
}
247239

248240
if ("downloading" %in% info) {
249241
## FIXME: Acknowledge to work on future
@@ -256,13 +248,7 @@ worker <- function(cluster = p2p_cluster_name(), host = "pipe.pico.sh", ssh_args
256248
} else if (state == "working") {
257249
## Withdrawal of future?
258250
if (m[["type"]] == "withdraw" && future %in% m[["future"]]) {
259-
info("Interrupting future %s, because client %s withdrew it", sQuote(client), sQuote(future))
260-
state <- "interrupt"
261-
rx$interrupt()
262-
future <- NULL
263-
client <- NULL
264-
## FIXME: Acknowledge withdrawal of future
265-
next
251+
signalCondition(future_withdraw())
266252
}
267253
}
268254
} ## if (length(m) > 0)
@@ -300,6 +286,12 @@ worker <- function(cluster = p2p_cluster_name(), host = "pipe.pico.sh", ssh_args
300286
future <<- NULL
301287
client <<- NULL
302288
## FIXME: Acknowledge withdrawal of future
289+
}, worker_interrupt = function(c) {
290+
info("Worker process was interrupted")
291+
state <- "waiting"
292+
future <- NULL
293+
client <- NULL
294+
## FIXME: Acknowledge withdrawal of future
303295
}, interrupt = function(c) {
304296
info("interrupted")
305297
## Interrupt worker

0 commit comments

Comments
 (0)