Module: Corkscrews::Monitor
- Defined in:
- ext/corkscrews/monitor.c
Class Method Summary collapse
- .available? ⇒ Boolean
- .clear_current_thread! ⇒ Object
- .register_current_thread! ⇒ Object
- .running? ⇒ Boolean
- .start! ⇒ Object
- .stop! ⇒ Object
Class Method Details
.available? ⇒ Boolean
100 101 102 103 104 105 |
# File 'ext/corkscrews/monitor.c', line 100
static VALUE
monitor_available_p(VALUE self)
{
(void)self;
return Qtrue;
}
|
.clear_current_thread! ⇒ Object
51 52 53 54 55 56 57 |
# File 'ext/corkscrews/monitor.c', line 51
static VALUE
monitor_clear_current_thread(VALUE self)
{
(void)self;
atomic_store(&cs_global.monitor_target_registered, 0);
return Qtrue;
}
|
.register_current_thread! ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'ext/corkscrews/monitor.c', line 42
static VALUE
monitor_register_current_thread(VALUE self)
{
(void)self;
target_thread = pthread_self();
atomic_store(&cs_global.monitor_target_registered, 1);
return Qtrue;
}
|
.running? ⇒ Boolean
93 94 95 96 97 98 |
# File 'ext/corkscrews/monitor.c', line 93
static VALUE
monitor_running_p(VALUE self)
{
(void)self;
return atomic_load(&cs_global.monitor_running) ? Qtrue : Qfalse;
}
|
.start! ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'ext/corkscrews/monitor.c', line 59
static VALUE
monitor_start(VALUE self)
{
(void)self;
if (atomic_exchange(&cs_global.monitor_running, 1)) {
return Qfalse;
}
if (pthread_create(&monitor_thread, NULL, monitor_loop, NULL) != 0) {
atomic_store(&cs_global.monitor_running, 0);
rb_raise(rb_eRuntimeError, "failed to start corkscrews monitor thread");
}
atomic_store(&monitor_thread_started, 1);
atomic_fetch_add(&cs_global.monitor_start_count, 1);
return Qtrue;
}
|
.stop! ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'ext/corkscrews/monitor.c', line 77
static VALUE
monitor_stop(VALUE self)
{
(void)self;
if (!atomic_exchange(&cs_global.monitor_running, 0)) {
return Qfalse;
}
if (atomic_exchange(&monitor_thread_started, 0)) {
pthread_join(monitor_thread, NULL);
}
atomic_fetch_add(&cs_global.monitor_stop_count, 1);
return Qtrue;
}
|