Skip to content

Commit

Permalink
Raise EM::Unsupported on EM.epoll/kqueue= on unsupported platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed Jun 16, 2009
1 parent d12f6e5 commit e627ab1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
10 changes: 6 additions & 4 deletions ext/rubymain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ static VALUE EmConnection;

static VALUE EM_eUnknownTimerFired;
static VALUE EM_eConnectionNotBound;
static VALUE EM_eUnsupported;

static VALUE Intern_at_signature;
static VALUE Intern_at_timers;
Expand Down Expand Up @@ -723,7 +724,7 @@ t__epoll
static VALUE t__epoll (VALUE self)
{
if (t__epoll_p(self) == Qfalse)
return Qfalse;
rb_raise (EM_eUnsupported, "epoll is not supported on this platform");

evma_set_epoll (1);
return Qtrue;
Expand All @@ -736,7 +737,7 @@ t__epoll_set
static VALUE t__epoll_set (VALUE self, VALUE val)
{
if (t__epoll_p(self) == Qfalse)
return Qfalse;
rb_raise (EM_eUnsupported, "epoll is not supported on this platform");

evma_set_epoll (val == Qtrue ? 1 : 0);
return val;
Expand All @@ -763,7 +764,7 @@ t__kqueue
static VALUE t__kqueue (VALUE self)
{
if (t__kqueue_p(self) == Qfalse)
return Qfalse;
rb_raise (EM_eUnsupported, "kqueue is not supported on this platform");

evma_set_kqueue (1);
return Qtrue;
Expand All @@ -776,7 +777,7 @@ t__kqueue_set
static VALUE t__kqueue_set (VALUE self, VALUE val)
{
if (t__kqueue_p(self) == Qfalse)
return Qfalse;
rb_raise (EM_eUnsupported, "kqueue is not supported on this platform");

evma_set_kqueue (val == Qtrue ? 1 : 0);
return val;
Expand Down Expand Up @@ -959,6 +960,7 @@ extern "C" void Init_rubyeventmachine()
rb_define_class_under (EmModule, "NoHandlerForAcceptedConnection", rb_eException);
EM_eConnectionNotBound = rb_define_class_under (EmModule, "ConnectionNotBound", rb_eRuntimeError);
EM_eUnknownTimerFired = rb_define_class_under (EmModule, "UnknownTimerFired", rb_eRuntimeError);
EM_eUnsupported = rb_define_class_under (EmModule, "Unsupported", rb_eRuntimeError);

rb_define_module_function (EmModule, "initialize_event_machine", (VALUE(*)(...))t_initialize_event_machine, 0);
rb_define_module_function (EmModule, "run_machine", (VALUE(*)(...))t_run_machine_without_threads, 0);
Expand Down
2 changes: 0 additions & 2 deletions tests/test_epoll.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def test_defer
n = 0
work_proc = proc {n += 1}
callback_proc = proc {EM.stop}
EM.epoll
EM.run {
EM.defer work_proc, callback_proc
}
Expand All @@ -120,7 +119,6 @@ def receive_data dgm

def test_datagrams
$in = $out = ""
EM.epoll
EM.run {
EM.open_datagram_socket "127.0.0.1", 9500, TestDatagramServer
EM.open_datagram_socket "127.0.0.1", 0, TestDatagramClient
Expand Down
2 changes: 0 additions & 2 deletions tests/test_next_tick.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,13 @@ class TestNextTick < Test::Unit::TestCase

def test_tick_arg
pr = proc {EM.stop}
EM.epoll
EM.run {
EM.next_tick pr
}
assert true
end

def test_tick_block
EM.epoll
EM.run {
EM.next_tick {EM.stop}
}
Expand Down

0 comments on commit e627ab1

Please sign in to comment.