class Async::Container::Keyed
Tracks a key/value pair such that unmarked keys can be identified and cleaned up. This helps implement persistent processes that start up child processes per directory or configuration file. If those directories and/or configuration files are removed, the child process can then be cleaned up automatically, because those key/value pairs will not be marked when reloading the container.
Attributes
The key. Normally a symbol or a file-system path. @attribute [Object]
The value. Normally a child instance of some sort. @attribute [Object]
Public Class Methods
# File lib/async/container/keyed.rb, line 28 def initialize(key, value) @key = key @value = value @marked = true end
Public Instance Methods
Clear the instance. This is normally done before reloading a container.
# File lib/async/container/keyed.rb, line 54 def clear! @marked = false end
Mark the instance. This will indiciate that the value is still in use/active.
# File lib/async/container/keyed.rb, line 49 def mark! @marked = true end
Has the instance been marked? @returns [Boolean]
# File lib/async/container/keyed.rb, line 44 def marked? @marked end
Stop the instance if it was not marked.
# File lib/async/container/keyed.rb, line 59 def stop? unless @marked @value.stop return true end end