Test pj++ proactor (compile only)
git-svn-id: https://svn.pjsip.org/repos/pjproject/main@37 74dad513-b988-da41-8d7b-12977e46ad98
This commit is contained in:
parent
85d3f45399
commit
12e13b7bb6
|
@ -15,8 +15,19 @@ class Pj_Object
|
|||
{
|
||||
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 @@ inline void *Pj_Object::operator new(unsigned int class_size, Pj_Pool *pool)
|
|||
{
|
||||
return pool->alloc(class_size);
|
||||
}
|
||||
inline void Pj_Object::operator delete(void *ptr)
|
||||
{
|
||||
}
|
||||
inline void Pj_Object::operator delete(void *ptr, Pj_Pool*)
|
||||
inline void *Pj_Object::operator new(unsigned int class_size, Pj_Pool &pool)
|
||||
{
|
||||
return pool.alloc(class_size);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -22,6 +22,15 @@ class Pj_Event_Handler;
|
|||
class Pj_Async_Op : public pj_ioqueue_op_key_t
|
||||
{
|
||||
public:
|
||||
//
|
||||
// Construct with null handler.
|
||||
// App must call set_handler() before use.
|
||||
//
|
||||
Pj_Async_Op()
|
||||
: handler_(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Constructor.
|
||||
//
|
||||
|
@ -31,6 +40,14 @@ public:
|
|||
pj_memset(this, 0, sizeof(pj_ioqueue_op_key_t));
|
||||
}
|
||||
|
||||
//
|
||||
// Set handler.
|
||||
//
|
||||
void set_handler(Pj_Event_Handler *handler)
|
||||
{
|
||||
handler_ = handler;
|
||||
}
|
||||
|
||||
//
|
||||
// Check whether operation is still pending for this key.
|
||||
//
|
||||
|
@ -97,7 +114,7 @@ public:
|
|||
}
|
||||
|
||||
//
|
||||
// Receive data.
|
||||
// Start async receive.
|
||||
//
|
||||
pj_status_t recv( Pj_Async_Op *op_key,
|
||||
void *buf, pj_ssize_t *len,
|
||||
|
@ -108,7 +125,7 @@ public:
|
|||
}
|
||||
|
||||
//
|
||||
// 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 @@ public:
|
|||
}
|
||||
|
||||
//
|
||||
// send()
|
||||
// Start async send()
|
||||
//
|
||||
pj_status_t send( Pj_Async_Op *op_key,
|
||||
const void *data, pj_ssize_t *len,
|
||||
|
@ -130,7 +147,7 @@ public:
|
|||
}
|
||||
|
||||
//
|
||||
// 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 @@ public:
|
|||
|
||||
#if PJ_HAS_TCP
|
||||
//
|
||||
// connect()
|
||||
// Start async connect()
|
||||
//
|
||||
pj_status_t connect(const Pj_Inet_Addr &addr)
|
||||
{
|
||||
|
@ -150,7 +167,7 @@ public:
|
|||
}
|
||||
|
||||
//
|
||||
// accept.
|
||||
// Start async accept().
|
||||
//
|
||||
pj_status_t accept( Pj_Async_Op *op_key,
|
||||
Pj_Socket *sock,
|
||||
|
@ -272,6 +289,8 @@ public:
|
|||
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 @@ public:
|
|||
return NULL;
|
||||
}
|
||||
|
||||
status;
|
||||
return status;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -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 @@ int main()
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue