Changeset 37


Ignore:
Timestamp:
Nov 9, 2005 3:51:49 PM (18 years ago)
Author:
bennylp
Message:

Test pj++ proactor (compile only)

Location:
pjproject/main/pjlib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/main/pjlib/include/pj++/pool.hpp

    r36 r37  
    1616public: 
    1717    void *operator new(unsigned int class_size, Pj_Pool *pool); 
    18     void operator delete(void*); 
    19     void operator delete(void*, Pj_Pool*); 
     18    void *operator new(unsigned int class_size, Pj_Pool &pool); 
     19 
     20    void operator delete(void*) 
     21    { 
     22    } 
     23 
     24    void operator delete(void*, Pj_Pool*) 
     25    { 
     26    } 
     27 
     28    void operator delete(void*, Pj_Pool&) 
     29    { 
     30    } 
    2031 
    2132    // 
     
    221232    return pool->alloc(class_size); 
    222233} 
    223 inline void Pj_Object::operator delete(void *ptr) 
    224 { 
    225 } 
    226 inline void Pj_Object::operator delete(void *ptr, Pj_Pool*) 
    227 { 
     234inline void *Pj_Object::operator new(unsigned int class_size, Pj_Pool &pool) 
     235{ 
     236    return pool.alloc(class_size); 
    228237} 
    229238 
  • pjproject/main/pjlib/include/pj++/proactor.hpp

    r36 r37  
    2424public: 
    2525    // 
     26    // Construct with null handler. 
     27    // App must call set_handler() before use. 
     28    // 
     29    Pj_Async_Op() 
     30        : handler_(NULL) 
     31    { 
     32    } 
     33 
     34    // 
    2635    // Constructor. 
    2736    // 
     
    3039    { 
    3140        pj_memset(this, 0, sizeof(pj_ioqueue_op_key_t)); 
     41    } 
     42 
     43    // 
     44    // Set handler. 
     45    // 
     46    void set_handler(Pj_Event_Handler *handler) 
     47    { 
     48        handler_ = handler; 
    3249    } 
    3350 
     
    98115 
    99116    // 
    100     // Receive data. 
     117    // Start async receive. 
    101118    // 
    102119    pj_status_t recv( Pj_Async_Op *op_key,  
     
    109126 
    110127    // 
    111     // Recvfrom() 
     128    // Start async recvfrom() 
    112129    // 
    113130    pj_status_t recvfrom( Pj_Async_Op *op_key,  
     
    121138 
    122139    // 
    123     // send() 
     140    // Start async send() 
    124141    // 
    125142    pj_status_t send( Pj_Async_Op *op_key,  
     
    131148 
    132149    // 
    133     // sendto() 
     150    // Start async sendto() 
    134151    // 
    135152    pj_status_t sendto( Pj_Async_Op *op_key, 
     
    143160#if PJ_HAS_TCP 
    144161    // 
    145     // connect() 
     162    // Start async connect() 
    146163    // 
    147164    pj_status_t connect(const Pj_Inet_Addr &addr) 
     
    151168 
    152169    // 
    153     // accept. 
     170    // Start async accept(). 
    154171    // 
    155172    pj_status_t accept( Pj_Async_Op *op_key, 
     
    273290        cb_.on_accept_complete  = &accept_complete_cb; 
    274291        cb_.on_connect_complete = &connect_complete_cb; 
     292 
     293        create(pool, max_fd, max_timer_entries); 
    275294    } 
    276295 
     
    305324        } 
    306325         
    307         status; 
     326        return status; 
    308327    } 
    309328 
  • pjproject/main/pjlib/src/pjlib++-test/main.cpp

    r36 r37  
    99#include <pj++/timer.hpp> 
    1010#include <pj++/tree.hpp> 
     11 
     12class My_Async_Op : public Pj_Async_Op 
     13{ 
     14}; 
     15 
     16class My_Event_Handler : public Pj_Event_Handler 
     17{ 
     18}; 
    1119 
    1220int main() 
     
    2533    delete plsem; 
    2634 
     35    Pj_Proactor proactor(pool, 100, 100); 
     36 
     37    My_Event_Handler *event_handler = new(the_pool) My_Event_Handler; 
     38    proactor.register_socket_handler(pool, event_handler); 
     39    proactor.unregister_handler(event_handler); 
     40 
    2741    return 0; 
    2842} 
Note: See TracChangeset for help on using the changeset viewer.