Module: Actuator

Defined in:
lib/actuator.rb,
lib/actuator/job.rb,
lib/actuator/mutex.rb,
lib/actuator/fiber_pool.rb,
ext/actuator/reactor.cpp

Defined Under Namespace

Classes: ConditionVariable, FiberPool, Job, JobKilledException, Mutex

Constant Summary collapse

VERSION =
"0.0.5"
JobKilled =
JobKilledException.new

Class Method Summary collapse

Class Method Details

.deferObject



18
19
20
# File 'lib/actuator.rb', line 18

def defer
  FiberPool.run { yield }
end

.next_tickObject



14
15
16
# File 'lib/actuator.rb', line 14

def next_tick
  Timer.in(0) { yield }
end

.nowObject



117
118
119
120
# File 'ext/actuator/reactor.cpp', line 117

static VALUE Actuator_now(VALUE klass)
{
    return DBL2NUM(clock_time());
}

.runObject



10
11
12
# File 'lib/actuator.rb', line 10

def run
  start { defer { yield } if block_given? }
end

.running?Boolean

Returns:

  • (Boolean)


122
123
124
125
# File 'ext/actuator/reactor.cpp', line 122

static VALUE Actuator_is_running(VALUE klass)
{
    return actuator->is_running ? Qtrue : Qfalse;
}

.startObject



127
128
129
130
131
132
133
134
135
# File 'ext/actuator/reactor.cpp', line 127

static VALUE Actuator_start(VALUE klass)
{
    if (actuator->is_running) {
        if (rb_block_given_p()) rb_yield(Qundef);
    } else {
        actuator->Start();
    }
    return Qnil;
}

.stopObject



137
138
139
140
141
# File 'ext/actuator/reactor.cpp', line 137

static VALUE Actuator_stop(VALUE klass)
{
    actuator->Stop();
    return Qnil;
}

.wakeObject



143
144
145
146
147
# File 'ext/actuator/reactor.cpp', line 143

static VALUE Actuator_wake(VALUE klass)
{
    actuator->Wake();
    return Qnil;
}