Class: Timer
- Inherits:
-
Object
- Object
- Timer
- Defined in:
- ext/actuator/timer.cpp
Overview
strcpy(inspected, RSTRING_PTR(obj));
Class Method Summary collapse
- .every(delay_value) ⇒ Object
- .in(delay_value) ⇒ Object
- .late_warning_us ⇒ Object
- .late_warning_us=(value) ⇒ Object
- .stats ⇒ Object
Instance Method Summary collapse
- #destroy ⇒ Object
- #destroyed? ⇒ Boolean
- #expires_at ⇒ Object
- #fire! ⇒ Object
- #initialize ⇒ Object constructor
Constructor Details
#initialize ⇒ Object
53 54 55 56 57 58 |
# File 'ext/actuator/timer.cpp', line 53 static VALUE Timer_initialize(VALUE self) { Timer *timer = Timer::Get(self); if (rb_block_given_p()) timer->SetCallback(rb_block_proc()); return self; } |
Class Method Details
.every(delay_value) ⇒ Object
100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'ext/actuator/timer.cpp', line 100 static VALUE Timer_every(VALUE self, VALUE delay_value) { rb_need_block(); Log::Debug("Timer.every"); double delay = NUM2DBL(delay_value); Timer *timer = new Timer(delay); timer->interval = delay; timer->SetCallback(rb_block_proc()); timer->Schedule(); current_object_count++; // We skip calling initialize on the timer to reduce overhead return timer->instance = Data_Wrap_Struct(TimerClass, Timer_mark, Timer_free, timer); } |
.in(delay_value) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 |
# File 'ext/actuator/timer.cpp', line 88 static VALUE Timer_in(VALUE self, VALUE delay_value) { rb_need_block(); Log::Debug("Timer.in"); Timer *timer = new Timer(NUM2DBL(delay_value)); timer->SetCallback(rb_block_proc()); timer->Schedule(); current_object_count++; // We skip calling initialize on the timer to reduce overhead return timer->instance = Data_Wrap_Struct(TimerClass, Timer_mark, Timer_free, timer); } |
.late_warning_us ⇒ Object
114 115 116 117 |
# File 'ext/actuator/timer.cpp', line 114 static VALUE Timer_late_warning_us(VALUE self) { return INT2NUM(late_warning_us); } |
.late_warning_us=(value) ⇒ Object
119 120 121 122 |
# File 'ext/actuator/timer.cpp', line 119 static VALUE Timer_late_warning_us_set(VALUE self, VALUE value) { return INT2NUM(late_warning_us = NUM2INT(value)); } |
.stats ⇒ Object
124 125 126 127 |
# File 'ext/actuator/timer.cpp', line 124 static VALUE Timer_stats(VALUE self) { return rb_sprintf("Frames: %d, Empty: %d, Fires: %d, Early: %d, Late: %d, Current: %d, Objects: %d, Scheduled: %d, GC: %d, Total: %d", last_second_frame_count, last_second_empty_frames, fired_last_second_count, last_second_earliest_fire < INT_MAX ? last_second_earliest_fire : -1, last_second_latest_fire, current_timer_count, current_object_count, all.size(), current_gc_registered_count, total_count); } |
Instance Method Details
#destroy ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'ext/actuator/timer.cpp', line 60 static VALUE Timer_destroy(VALUE self) { Timer *timer = Timer::Get(self); if (timer) timer->Destroy(); else rb_raise(rb_eRuntimeError, "Timer instance has no allocated timer struct"); return Qnil; } |
#destroyed? ⇒ Boolean
75 76 77 78 |
# File 'ext/actuator/timer.cpp', line 75 static VALUE Timer_is_destroyed(VALUE self) { return (Timer::Get(self))->is_destroyed ? Qtrue : Qfalse; } |
#expires_at ⇒ Object
70 71 72 73 |
# File 'ext/actuator/timer.cpp', line 70 static VALUE Timer_expires_at(VALUE self) { return DBL2NUM(Timer::Get(self)->at); } |
#fire! ⇒ Object
80 81 82 83 84 85 86 |
# File 'ext/actuator/timer.cpp', line 80 static VALUE Timer_fire_bang(VALUE self) { Timer *timer = Timer::Get(self); if (timer->is_destroyed || !timer->is_scheduled) return Qnil; timer->ExpireImmediately(); return Qtrue; } |