Learn R Programming

ipc (version 0.1.4)

AsyncInterruptor: An interruptor useful for stopping child processes.

Description

An interruptor useful for stopping child processes.

An interruptor useful for stopping child processes.

Arguments

Methods


Method new()

Create the object

Usage

AsyncInterruptor$new(queue = shinyQueue())

Arguments

queue

The underlying queue object to use for interruption


Method interrupt()

signal an error

Usage

AsyncInterruptor$interrupt(msg = "Signaled Interrupt")

Arguments

msg

The error message


Method execInterrupts()

Execute any interruptions that have been signaled

Usage

AsyncInterruptor$execInterrupts()


Method getInterrupts()

Get any interruptions that have been signaled without throwing them as errors

Usage

AsyncInterruptor$getInterrupts()


Method destroy()

Cleans up object after use

Usage

AsyncInterruptor$destroy()


Method clone()

The objects of this class are cloneable with this method.

Usage

AsyncInterruptor$clone(deep = FALSE)

Arguments

deep

Whether to make a deep clone.

Details

This class is a simple wrapper around a Queue object making adding interrupt checking to future code easy to implement and read.

Methods

initialize(queue=shinyQueue())

Creates a new interruptor.

interrupt(msg="Signaled Interrupt")

Signals an interrupt

execInterrupts()

Executes anything pushed to the queue, including interrupts.

getInterrupts()

Gets the result of the queue's executing, not throwing the interrupts.

Examples

Run this code
library(future)
strategy <- "future::multisession"
plan(strategy)
inter <- AsyncInterruptor$new()
fut <- future({
  for(i in 1:100){
    Sys.sleep(.01)
    inter$execInterrupts()
  }
})
inter$interrupt("Error: Stop Future")
try(value(fut))
inter$destroy()

# Clean up multisession cluster
plan(sequential)

Run the code above in your browser using DataLab