Test pj++ proactor (compile only)

git-svn-id: https://svn.pjsip.org/repos/pjproject/main@37 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjlib/include/pj++/pool.hpp b/pjlib/include/pj++/pool.hpp
index 611cd7a..c1991d5 100644
--- a/pjlib/include/pj++/pool.hpp
+++ b/pjlib/include/pj++/pool.hpp
@@ -15,8 +15,19 @@
 {

 public:

     void *operator new(unsigned int class_size, Pj_Pool *pool);

-    void operator delete(void*);

-    void operator delete(void*, Pj_Pool*);

+    void *operator new(unsigned int class_size, Pj_Pool &pool);

+

+    void operator delete(void*)

+    {

+    }

+

+    void operator delete(void*, Pj_Pool*)

+    {

+    }

+

+    void operator delete(void*, Pj_Pool&)

+    {

+    }

 

     //

     // Inline implementations at the end of this file.

@@ -220,11 +231,9 @@
 {

     return pool->alloc(class_size);

 }

-inline void Pj_Object::operator delete(void *ptr)

+inline void *Pj_Object::operator new(unsigned int class_size, Pj_Pool &pool)

 {

-}

-inline void Pj_Object::operator delete(void *ptr, Pj_Pool*)

-{

+    return pool.alloc(class_size);

 }

 

 //

diff --git a/pjlib/include/pj++/proactor.hpp b/pjlib/include/pj++/proactor.hpp
index 7021a5a..891dd75 100644
--- a/pjlib/include/pj++/proactor.hpp
+++ b/pjlib/include/pj++/proactor.hpp
@@ -23,6 +23,15 @@
 {

 public:

     //

+    // Construct with null handler.

+    // App must call set_handler() before use.

+    //

+    Pj_Async_Op()

+        : handler_(NULL)

+    {

+    }

+

+    //

     // Constructor.

     //

     explicit Pj_Async_Op(Pj_Event_Handler *handler)

@@ -32,6 +41,14 @@
     }

 

     //

+    // Set handler.

+    //

+    void set_handler(Pj_Event_Handler *handler)

+    {

+        handler_ = handler;

+    }

+

+    //

     // Check whether operation is still pending for this key.

     //

     bool is_pending();

@@ -97,7 +114,7 @@
     }

 

     //

-    // Receive data.

+    // Start async receive.

     //

     pj_status_t recv( Pj_Async_Op *op_key, 

                       void *buf, pj_ssize_t *len, 

@@ -108,7 +125,7 @@
     }

 

     //

-    // Recvfrom()

+    // Start async recvfrom()

     //

     pj_status_t recvfrom( Pj_Async_Op *op_key, 

                           void *buf, pj_ssize_t *len, unsigned flags,

@@ -120,7 +137,7 @@
     }

 

     //

-    // send()

+    // Start async send()

     //

     pj_status_t send( Pj_Async_Op *op_key, 

                       const void *data, pj_ssize_t *len, 

@@ -130,7 +147,7 @@
     }

 

     //

-    // sendto()

+    // Start async sendto()

     //

     pj_status_t sendto( Pj_Async_Op *op_key,

                         const void *data, pj_ssize_t *len, unsigned flags,

@@ -142,7 +159,7 @@
 

 #if PJ_HAS_TCP

     //

-    // connect()

+    // Start async connect()

     //

     pj_status_t connect(const Pj_Inet_Addr &addr)

     {

@@ -150,7 +167,7 @@
     }

 

     //

-    // accept.

+    // Start async accept().

     //

     pj_status_t accept( Pj_Async_Op *op_key,

                         Pj_Socket *sock, 

@@ -272,6 +289,8 @@
         cb_.on_write_complete   = &write_complete_cb;

         cb_.on_accept_complete  = &accept_complete_cb;

         cb_.on_connect_complete = &connect_complete_cb;

+

+        create(pool, max_fd, max_timer_entries);

     }

 

     //

@@ -304,7 +323,7 @@
             return NULL;

         }

         

-        status;

+        return status;

     }

 

     //

diff --git a/pjlib/src/pjlib++-test/main.cpp b/pjlib/src/pjlib++-test/main.cpp
index 4a6d0aa..99b7f8d 100644
--- a/pjlib/src/pjlib++-test/main.cpp
+++ b/pjlib/src/pjlib++-test/main.cpp
@@ -9,6 +9,14 @@
 #include <pj++/timer.hpp>

 #include <pj++/tree.hpp>

 

+class My_Async_Op : public Pj_Async_Op

+{

+};

+

+class My_Event_Handler : public Pj_Event_Handler

+{

+};

+

 int main()

 {

     Pjlib lib;

@@ -24,6 +32,12 @@
     plsem = new(pool) Pj_Semaphore_Lock(pool);

     delete plsem;

 

+    Pj_Proactor proactor(pool, 100, 100);

+

+    My_Event_Handler *event_handler = new(the_pool) My_Event_Handler;

+    proactor.register_socket_handler(pool, event_handler);

+    proactor.unregister_handler(event_handler);

+

     return 0;

 }