On this page:
Custodian
Custodian.shutdown_  all
Custodian.is_  shutdown
Custodian.current
Custodian.Box
Custodian.Box.value
8.16.0.4

16.1 Custodians🔗ℹ

 import: rhombus/custodian package: rhombus-lib

A custodian manages objects such as threads, file-stream ports, network connections, and other custodians. Whenever a thread, etc., is created, it is placed under the management of the current custodian as determined by the Custodian.current parameter.

A custodian box created with Custodian.Box strongly holds onto a value placed in the box until the box’s custodian is shut down.

class

class Custodian():

  constructor (~parent: cust :: Custodian = Custodian.current())

Represents a custodian.

A new custodian is always created with some existing custodian as its parent. If the parent custodian is shut down, then the child is shut down, too.

method

method (cust :: Custodian).shutdown_all() :: Void

 

method

method (cust :: Custodian).is_shutdown() :: Boolean

The Custodian.shutdown_all method closes all objects managed by cust.

The Custodian.is_shutdown method reports whether a custodian has been shut down already. A custodian that has been shut down cannot become the owner of new objects.

A context parameter that determines the custodian for newly created object such as threads and file-stream ports.

class

class Custodian.Box():

  constructor (v :: Any,

               ~custodian: cust :: Custodian = Custodian.current())

Returns a custodian box that contains v as long as cust has not been shut down. If cust is already shut down, the custodian box’s value is immediately removed.

Returns the value in the given custodian box bx, or #false if the value has been removed.