class NewRelic::Starter::Latch
NewRelic::Starter::Latch
indicates whether the New Relic agent should be started.
Public Class Methods
NewRelic::Starter::Latch.new → latch
click to toggle source
NewRelic::Starter::Latch.new(path) → latch
Returns a new {Latch} object.
The state of the latch is stored in memory mapped by mmap(2) and shared with a forked process.
If path
is specified, the memory mapping is backed by the file and the state of the latch is shared with other latches backed by the same file.
NewRelic::Starter::Latch.new #=> #<NewRelic::Starter::Latch:0x00007fbecb04f038> NewRelic::Starter::Latch.new("/path/to/latch") #=> #<NewRelic::Starter::Latch:0x00007fbec9808010>
static VALUE latch_initialize(int argc, VALUE *argv, VALUE self) { int fd = -1; void *addr; char *path = rb_check_arity(argc, 0, 1) ? RSTRING_PTR(argv[0]) : NULL; if (path != NULL) { fd = open_latch_file(path); } addr = mmap(NULL, 1, PROT_READ|PROT_WRITE, (fd == -1 ? MAP_ANONYMOUS|MAP_SHARED : MAP_SHARED), fd, 0); if (addr == MAP_FAILED) { int e = errno; close(fd); rb_raise(eError, "failed to create mapping for latch: %s", strerror(e)); } close(fd); DATA_PTR(self) = addr; return self; }
Public Instance Methods
open → nil
click to toggle source
Opens the latch.
latch = NewRelic::Starter::Latch.new latch.opened? #=> false latch.open latch.opened? #=> true
static VALUE latch_open(VALUE self) { uint8_t *l = check_latch(self); *l = 1; return Qnil; }
opened? → boolean
click to toggle source
Returns true if the latch is opened.
latch = NewRelic::Starter::Latch.new latch.opened? #=> false latch.open latch.opened? #=> true
static VALUE latch_opened(VALUE self) { return *check_latch(self) == 1 ? Qtrue : Qfalse; }