Class: Libevent::Base
- Inherits:
-
Object
- Object
- Libevent::Base
- Defined in:
- lib/libevent/base.rb,
ext/libevent_ext/base.c
Instance Attribute Summary (collapse)
-
- (Object) signals
readonly
Returns the value of attribute signals.
Instance Method Summary (collapse)
-
- (Object) break_loop
Abort the active event_base loop immediately.
-
- (Object) dispatch
Event dispatching loop.
-
- (Object) exit_loop
Exit the event loop after the specified time.
-
- (Base) initialize
constructor
Create new event base.
-
- (Object) trap_signal(name, &block)
Create new signal with handler as block and add signal to event base.
Constructor Details
- (Base) initialize
Create new event base
4 5 6 |
# File 'lib/libevent/base.rb', line 4 def initialize @signals = [] end |
Instance Attribute Details
- (Object) signals (readonly)
Returns the value of attribute signals
8 9 10 |
# File 'lib/libevent/base.rb', line 8 def signals @signals end |
Instance Method Details
- (Object) break_loop
Abort the active event_base loop immediately.
It will abort the loop after the next event is completed; event_base_loopbreak() is typically invoked from this event's callback. This behavior is analogous to the "break;" statement. Subsequent invocations of event_loop() will proceed normally.
|
|
# File 'ext/libevent_ext/base.c'
static VALUE t_break_loop(VALUE self) {
Libevent_Base *base;
int status;
Data_Get_Struct(self, Libevent_Base, base);
status = event_base_loopbreak(base->ev_base);
return (status == -1 ? Qfalse : Qtrue);
}
|
- (Object) dispatch
Event dispatching loop.
This loop will run the event base until either there are no more added events, or until something calls Libevent::Base#break_loop or Base#exit_loop.
|
|
# File 'ext/libevent_ext/base.c'
static VALUE t_dispatch(VALUE self) {
Libevent_Base *base;
int status;
Data_Get_Struct(self, Libevent_Base, base);
status = event_base_dispatch(base->ev_base);
return INT2FIX(status);
}
|
- (Object) exit_loop
specified time is not implemented
Exit the event loop after the specified time
|
|
# File 'ext/libevent_ext/base.c'
static VALUE t_exit_loop(VALUE self) {
Libevent_Base *base;
int status;
Data_Get_Struct(self, Libevent_Base, base);
status = event_base_loopexit(base->ev_base, NULL);
return (status == -1 ? Qfalse : Qtrue);
}
|
- (Object) trap_signal(name, &block)
Create new signal with handler as block and add signal to event base
13 14 15 |
# File 'lib/libevent/base.rb', line 13 def trap_signal(name, &block) @signals << Signal.new(self, name, block) end |