Skip to content
This repository has been archived by the owner on Sep 10, 2021. It is now read-only.

Commit

Permalink
Add EM.kqueue= and EM.epoll=
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed Mar 16, 2009
1 parent bb05a9c commit 28fdba4
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 35 deletions.
20 changes: 10 additions & 10 deletions ext/cmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,22 +491,22 @@ extern "C" int evma_get_outbound_data_size (const char *binding)
}


/***********
evma__epoll
***********/
/**************
evma_set_epoll
**************/

extern "C" void evma__epoll()
extern "C" void evma_set_epoll (int use)
{
bUseEpoll = 1;
bUseEpoll = !!use;
}

/************
evma__kqueue
************/
/***************
evma_set_kqueue
***************/

extern "C" void evma__kqueue()
extern "C" void evma_set_kqueue (int use)
{
bUseKqueue = 1;
bUseKqueue = !!use;
}


Expand Down
2 changes: 1 addition & 1 deletion ext/cplusplus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ EM::Run

void EM::Run (void (*start_func)())
{
evma__epoll();
evma_set_epoll (1);
evma_initialize_library (EM::Callback);
if (start_func)
AddTimer (0, start_func);
Expand Down
5 changes: 2 additions & 3 deletions ext/eventmachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,8 @@ extern "C" {

int evma_set_rlimit_nofile (int n_files);

// Temporary:
void evma__epoll();
void evma__kqueue();
void evma_set_epoll (int use);
void evma_set_kqueue (int use);

#if __cplusplus
}
Expand Down
73 changes: 52 additions & 21 deletions ext/rubymain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -609,17 +609,6 @@ static VALUE t_read_keyboard (VALUE self)
}


/********
t__epoll
********/

static VALUE t__epoll (VALUE self)
{
// Temporary.
evma__epoll();
return Qnil;
}

/**********
t__epoll_p
**********/
Expand All @@ -633,18 +622,33 @@ static VALUE t__epoll_p (VALUE self)
#endif
}

/********
t__epoll
********/

/*********
t__kqueue
*********/
static VALUE t__epoll (VALUE self)
{
if (t__epoll_p(self) == Qfalse)
return Qfalse;

static VALUE t__kqueue (VALUE self)
evma_set_epoll (1);
return Qtrue;
}

/***********
t__epoll_set
***********/

static VALUE t__epoll_set (VALUE self, VALUE val)
{
// Temporary.
evma__kqueue();
return Qnil;
if (t__epoll_p(self) == Qfalse)
return Qfalse;

evma_set_epoll (val == Qtrue ? 1 : 0);
return val;
}


/***********
t__kqueue_p
***********/
Expand All @@ -658,6 +662,32 @@ static VALUE t__kqueue_p (VALUE self)
#endif
}

/*********
t__kqueue
*********/

static VALUE t__kqueue (VALUE self)
{
if (t__kqueue_p(self) == Qfalse)
return Qfalse;

evma_set_kqueue (1);
return Qtrue;
}

/*************
t__kqueue_set
*************/

static VALUE t__kqueue_set (VALUE self, VALUE val)
{
if (t__kqueue_p(self) == Qfalse)
return Qfalse;

evma_set_kqueue (val == Qtrue ? 1 : 0);
return val;
}


/****************
t_send_file_data
Expand Down Expand Up @@ -821,11 +851,12 @@ extern "C" void Init_rubyeventmachine()
rb_define_module_function (EmModule, "set_rlimit_nofile", (VALUE(*)(...))t_set_rlimit_nofile, 1);
rb_define_module_function (EmModule, "get_connection_count", (VALUE(*)(...))t_get_connection_count, 0);

// Temporary:
rb_define_module_function (EmModule, "epoll", (VALUE(*)(...))t__epoll, 0);
rb_define_module_function (EmModule, "kqueue", (VALUE(*)(...))t__kqueue, 0);

rb_define_module_function (EmModule, "epoll=", (VALUE(*)(...))t__epoll_set, 1);
rb_define_module_function (EmModule, "epoll?", (VALUE(*)(...))t__epoll_p, 0);

rb_define_module_function (EmModule, "kqueue", (VALUE(*)(...))t__kqueue, 0);
rb_define_module_function (EmModule, "kqueue=", (VALUE(*)(...))t__kqueue_set, 1);
rb_define_module_function (EmModule, "kqueue?", (VALUE(*)(...))t__kqueue_p, 0);

rb_define_method (EmConnection, "get_outbound_data_size", (VALUE(*)(...))conn_get_outbound_data_size, 0);
Expand Down

0 comments on commit 28fdba4

Please sign in to comment.