Class: OsCtld::Container::RunConfiguration::InitLease

Inherits:
Object
  • Object
show all
Defined in:
lib/osctld/container/run_configuration.rb

Overview

A short-lived reference to one descriptor-authenticated init identity. Retirement rejects new leases and waits for existing leases to close, so callers can release ordinary container/run locks before blocking work.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(run_conf, identity) ⇒ InitLease

Returns a new instance of InitLease.



15
16
17
18
19
20
# File 'lib/osctld/container/run_configuration.rb', line 15

def initialize(run_conf, identity)
  @run_conf = run_conf
  @identity = identity
  @mutex = Mutex.new
  @closed = false
end

Instance Attribute Details

#identity ⇒ Object (readonly)

Returns the value of attribute identity.



13
14
15
# File 'lib/osctld/container/run_configuration.rb', line 13

def identity
  @identity
end

Instance Method Details

#close ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/osctld/container/run_configuration.rb', line 22

def close
  release = @mutex.synchronize do
    next false if @closed

    @closed = true
    true
  end
  return unless release

  begin
    @identity.close
  ensure
    @run_conf.send(:release_init_lease)
    @identity = nil
  end
end