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

key[R]

The key. Normally a symbol or a file-system path. @attribute [Object]

value[R]

The value. Normally a child instance of some sort. @attribute [Object]

Public Class Methods

new(key, value) click to toggle source
# File lib/async/container/keyed.rb, line 28
def initialize(key, value)
        @key = key
        @value = value
        @marked = true
end

Public Instance Methods

clear!() click to toggle source

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!() click to toggle source

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
marked?() click to toggle source

Has the instance been marked? @returns [Boolean]

# File lib/async/container/keyed.rb, line 44
def marked?
        @marked
end
stop?() click to toggle source

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