diff options
author | Nanang Izzuddin <nanang@teluu.com> | 2015-11-06 04:18:46 +0000 |
---|---|---|
committer | Nanang Izzuddin <nanang@teluu.com> | 2015-11-06 04:18:46 +0000 |
commit | fa8856aca65908663819c607297271a6bf0500ea (patch) | |
tree | d13ac79b7d56e52c1420486431e1392f8cd2e293 /pjlib/include/pj | |
parent | 25f41e95c2de6a280ba4159c73aa97d364c04db6 (diff) |
Close #1894: Improve ioqueue performance on multithreadeded environment.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5194 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/include/pj')
-rw-r--r-- | pjlib/include/pj/ioqueue.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/pjlib/include/pj/ioqueue.h b/pjlib/include/pj/ioqueue.h index 44ff2309..a8a33f7a 100644 --- a/pjlib/include/pj/ioqueue.h +++ b/pjlib/include/pj/ioqueue.h @@ -303,6 +303,28 @@ typedef enum pj_ioqueue_operation_e # define PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL (16) #endif + +/** + * This macro specifies the maximum event candidates collected by each + * polling thread to be able to reach maximum number of processed events + * (i.e: PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL) in each poll cycle. + * An event candidate will be dispatched to application as event unless + * it is already being dispatched by other polling thread. So in order to + * anticipate such race condition, each poll operation should collects its + * event candidates more than PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL, the + * recommended value is (PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL * + * number of polling threads). + * + * The value is only meaningfull when specified during PJLIB build and + * is only effective on multiple polling threads environment. + */ +#if !defined(PJ_IOQUEUE_MAX_CAND_EVENTS) || \ + PJ_IOQUEUE_MAX_CAND_EVENTS < PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL +# undef PJ_IOQUEUE_MAX_CAND_EVENTS +# define PJ_IOQUEUE_MAX_CAND_EVENTS PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL +#endif + + /** * When this flag is specified in ioqueue's recv() or send() operations, * the ioqueue will always mark the operation as asynchronous. @@ -504,6 +526,17 @@ PJ_DECL(pj_status_t) pj_ioqueue_set_concurrency(pj_ioqueue_key_t *key, PJ_DECL(pj_status_t) pj_ioqueue_lock_key(pj_ioqueue_key_t *key); /** + * Try to acquire the key's mutex. When the key's concurrency is disabled, + * application may call this function to synchronize its operation + * with the key's callback. + * + * @param key The key that was previously obtained from registration. + * + * @return PJ_SUCCESS on success or the appropriate error code. + */ +PJ_DECL(pj_status_t) pj_ioqueue_trylock_key(pj_ioqueue_key_t *key); + +/** * Release the lock previously acquired with pj_ioqueue_lock_key(). * * @param key The key that was previously obtained from registration. |