Skip to content

Commit

Permalink
Add EM.get_max_timers (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm1 committed Feb 11, 2009
1 parent f79e0ff commit bc22990
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ext/cmain.cpp
Expand Up @@ -412,6 +412,17 @@ extern "C" void evma_set_timer_quantum (int interval)
EventMachine->SetTimerQuantum (interval);
}


/************************
evma_get_max_timer_count
************************/

extern "C" int evma_get_max_timer_count()
{
return EventMachine_t::GetMaxTimerCount();
}


/************************
evma_set_max_timer_count
************************/
Expand Down
9 changes: 9 additions & 0 deletions ext/em.cpp
Expand Up @@ -45,6 +45,15 @@ static int MaxOutstandingTimers = 1000;
*/
static struct sockaddr *name2address (const char *server, int port, int *family, int *bind_size);

/***************************************
STATIC EventMachine_t::GetMaxTimerCount
***************************************/

int EventMachine_t::GetMaxTimerCount()
{
return MaxOutstandingTimers;
}


/***************************************
STATIC EventMachine_t::SetMaxTimerCount
Expand Down
1 change: 1 addition & 0 deletions ext/em.h
Expand Up @@ -69,6 +69,7 @@ class EventMachine_t
class EventMachine_t
{
public:
static int GetMaxTimerCount();
static void SetMaxTimerCount (int);

public:
Expand Down
1 change: 1 addition & 0 deletions ext/eventmachine.h
Expand Up @@ -74,6 +74,7 @@ extern "C" {
int evma_report_connection_error_status (const char *binding);
void evma_signal_loopbreak();
void evma_set_timer_quantum (int);
int evma_get_max_timer_count();
void evma_set_max_timer_count (int);
void evma_setuid_string (const char *username);
void evma_stop_machine();
Expand Down
10 changes: 10 additions & 0 deletions ext/rubymain.cpp
Expand Up @@ -458,6 +458,15 @@ static VALUE t_set_timer_quantum (VALUE self, VALUE interval)
return Qnil;
}

/********************
t_get_max_timer_count
********************/

static VALUE t_get_max_timer_count (VALUE self)
{
return INT2FIX (evma_get_max_timer_count());
}

/********************
t_set_max_timer_count
********************/
Expand Down Expand Up @@ -729,6 +738,7 @@ extern "C" void Init_rubyeventmachine()
rb_define_module_function (EmModule, "signal_loopbreak", (VALUE(*)(...))t_signal_loopbreak, 0);
rb_define_module_function (EmModule, "library_type", (VALUE(*)(...))t_library_type, 0);
rb_define_module_function (EmModule, "set_timer_quantum", (VALUE(*)(...))t_set_timer_quantum, 1);
rb_define_module_function (EmModule, "get_max_timer_count", (VALUE(*)(...))t_get_max_timer_count, 0);
rb_define_module_function (EmModule, "set_max_timer_count", (VALUE(*)(...))t_set_max_timer_count, 1);
rb_define_module_function (EmModule, "setuid_string", (VALUE(*)(...))t_setuid_string, 1);
rb_define_module_function (EmModule, "invoke_popen", (VALUE(*)(...))t_invoke_popen, 1);
Expand Down
6 changes: 6 additions & 0 deletions lib/eventmachine.rb
Expand Up @@ -924,6 +924,12 @@ def self::set_max_timers ct
set_max_timer_count ct
end

# Gets the current maximum number of allowed timers
#
def self::get_max_timers
get_max_timer_count
end

#--
# The is the responder for the loopback-signalled event.
# It can be fired either by code running on a separate thread (EM#defer) or on
Expand Down

0 comments on commit bc22990

Please sign in to comment.