Changeset 347

Show
Ignore:
Timestamp:
06/01/07 12:35:49 (2 years ago)
Author:
blackhedd
Message:

added EventMachine::Connection#get_outbound_data_size

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • version_0/ChangeLog

    r345 r347  
    303001Jun07: Added EM, a "pseudo-alias" for EventMachine. 
    313101Jun07: Added EM#next_tick. 
     3201Jun07: Added EM::Connection#get_outbound_data_size 
  • version_0/ext/cmain.cpp

    r336 r347  
    304304 
    305305 
    306  
     306/*************************** 
     307evma_get_outbound_data_size 
     308***************************/ 
     309 
     310extern "C" int evma_get_outbound_data_size (const char *binding) 
     311
     312        if (!EventMachine) 
     313                throw std::runtime_error ("not initialized"); 
     314        EventableDescriptor *ed = dynamic_cast <EventableDescriptor*> (Bindable_t::GetObject (binding)); 
     315        return ed ? ed->GetOutboundDataSize() : 0; 
     316
     317 
     318 
  • version_0/ext/eventmachine.h

    r336 r347  
    4949        int evma_get_comm_inactivity_timeout (const char *binding, /*out*/int *value); 
    5050        int evma_set_comm_inactivity_timeout (const char *binding, /*in,out*/int *value); 
     51        int evma_get_outbound_data_size (const char *binding); 
     52 
    5153        void evma_close_connection (const char *binding, int after_writing); 
    5254        void evma_signal_loopbreak(); 
  • version_0/ext/rubymain.cpp

    r336 r347  
    2929 
    3030static VALUE EmModule; 
     31static VALUE EmConnection; 
     32 
     33static VALUE Intern_at_signature; 
    3134 
    3235 
     
    324327 
    325328 
     329 
     330/*************************** 
     331conn_get_outbound_data_size 
     332***************************/ 
     333 
     334static VALUE conn_get_outbound_data_size (VALUE self) 
     335{ 
     336        VALUE sig = rb_ivar_get (self, Intern_at_signature); 
     337        return INT2NUM (evma_get_outbound_data_size (StringValuePtr(sig))); 
     338} 
     339 
     340 
     341 
    326342/********************* 
    327343Init_rubyeventmachine 
     
    330346extern "C" void Init_rubyeventmachine() 
    331347{ 
     348        // Tuck away some symbol values so we don't have to look 'em up every time we need 'em. 
     349        Intern_at_signature = rb_intern ("@signature"); 
     350 
    332351        // INCOMPLETE, we need to define class Connections inside module EventMachine 
    333352        // run_machine and run_machine_without_threads are now identical. 
    334353        // Must deprecate the without_threads variant. 
    335354        EmModule = rb_define_module ("EventMachine"); 
     355        EmConnection = rb_define_class_under (EmModule, "Connection", rb_cObject); 
     356 
     357        rb_define_class_under (EmModule, "ConnectionNotBound", rb_eException); 
     358        rb_define_class_under (EmModule, "NoHandlerForAcceptedConnection", rb_eException); 
     359        rb_define_class_under (EmModule, "UnknownTimerFired", rb_eException); 
     360 
    336361        rb_define_module_function (EmModule, "initialize_event_machine", (VALUE(*)(...))t_initialize_event_machine, 0); 
    337362        rb_define_module_function (EmModule, "run_machine", (VALUE(*)(...))t_run_machine_without_threads, 0); 
     
    355380        rb_define_module_function (EmModule, "invoke_popen", (VALUE(*)(...))t_invoke_popen, 2); 
    356381 
    357   // Provisional: 
     382       // Provisional: 
    358383        rb_define_module_function (EmModule, "_write_file", (VALUE(*)(...))t__write_file, 1); 
    359384 
     
    362387        rb_define_module_function (EmModule, "set_comm_inactivity_timeout", (VALUE(*)(...))t_set_comm_inactivity_timeout, 2); 
    363388 
    364         rb_define_class_under (EmModule, "ConnectionNotBound", rb_eException); 
    365         rb_define_class_under (EmModule, "NoHandlerForAcceptedConnection", rb_eException); 
    366         rb_define_class_under (EmModule, "UnknownTimerFired", rb_eException); 
     389        rb_define_method (EmConnection, "get_outbound_data_size", (VALUE(*)(...))conn_get_outbound_data_size, 0); 
    367390 
    368391        rb_define_const (EmModule, "TimerFired", INT2NUM(100));