summaryrefslogtreecommitdiff
path: root/pjlib/include/pj
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2005-11-06 13:32:11 +0000
committerBenny Prijono <bennylp@teluu.com>2005-11-06 13:32:11 +0000
commit97611d9f0a7809a759a0a0603f6d45f5822ad170 (patch)
treecfef74513d998e880d13bb0da8d1f465559c3861 /pjlib/include/pj
parent7c7300624eb867fa7c1ea52b9c636889aac60e80 (diff)
Put common ioqueue functionalities in separate file to be used by both select() and epoll
git-svn-id: http://svn.pjsip.org/repos/pjproject/main@12 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjlib/include/pj')
-rw-r--r--pjlib/include/pj/ioqueue.h24
-rw-r--r--pjlib/include/pj/sock.h27
2 files changed, 31 insertions, 20 deletions
diff --git a/pjlib/include/pj/ioqueue.h b/pjlib/include/pj/ioqueue.h
index 6a7b827e..2e084fd3 100644
--- a/pjlib/include/pj/ioqueue.h
+++ b/pjlib/include/pj/ioqueue.h
@@ -82,11 +82,10 @@ PJ_BEGIN_DECL
*
* The items below describe rules that must be obeyed when using the I/O
* queue, with regard to concurrency:
- * - in general, the I/O queue is thread safe (assuming the lock strategy
- * is not changed to disable mutex protection). All operations, except
- * unregistration which is described below, can be safely invoked
- * simultaneously by multiple threads.
- * - however, <b>care must be taken when unregistering a key</b> from the
+ * - simultaneous operations (by different threads) to different key is safe.
+ * - simultaneous operations to the same key is also safe, except
+ * <b>unregistration</b>, which is described below.
+ * - <b>care must be taken when unregistering a key</b> from the
* ioqueue. Application must take care that when one thread is issuing
* an unregistration, other thread is not simultaneously invoking an
* operation <b>to the same key</b>.
@@ -205,11 +204,16 @@ typedef enum pj_ioqueue_operation_e
} pj_ioqueue_operation_e;
-/**
- * Indicates that the I/O Queue should be created to handle reasonable
- * number of threads.
- */
-#define PJ_IOQUEUE_DEFAULT_THREADS 0
+/**
+ * This macro specifies the maximum number of events that can be
+ * processed by the ioqueue on a single poll cycle, on implementation
+ * that supports it. The value is only meaningfull when specified
+ * during PJLIB build.
+ */
+#ifndef PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL
+# define PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL (16)
+#endif
+
/**
* Create a new I/O Queue framework.
diff --git a/pjlib/include/pj/sock.h b/pjlib/include/pj/sock.h
index 79f161f2..6dfbaf29 100644
--- a/pjlib/include/pj/sock.h
+++ b/pjlib/include/pj/sock.h
@@ -69,7 +69,7 @@ extern const pj_uint16_t PJ_SOCK_RDM; /**< Reliably-delivered messages. */
/**
- * Socket level specified in #pj_sock_setsockopt().
+ * Socket level specified in #pj_sock_setsockopt() or #pj_sock_getsockopt().
* APPLICATION MUST USE THESE VALUES INSTEAD OF NORMAL SOL_*, BECAUSE
* THE LIBRARY WILL TRANSLATE THE VALUE TO THE NATIVE VALUE.
*/
@@ -78,6 +78,15 @@ extern const pj_uint16_t PJ_SOL_IP; /**< IP level. */
extern const pj_uint16_t PJ_SOL_TCP; /**< TCP level. */
extern const pj_uint16_t PJ_SOL_UDP; /**< UDP level. */
extern const pj_uint16_t PJ_SOL_IPV6; /**< IP version 6 */
+
+/**
+ * Values to be specified as \c optname when calling #pj_sock_setsockopt()
+ * or #pj_sock_getsockopt().
+ */
+extern const pj_uint16_t PJ_SO_TYPE; /**< Socket type. */
+extern const pj_uint16_t PJ_SO_RCVBUF; /**< Buffer size for receive. */
+extern const pj_uint16_t PJ_SO_SNDBUF; /**< Buffer size for send. */
+
/**
* Flags to be specified in #pj_sock_recv, #pj_sock_send, etc.
@@ -419,7 +428,7 @@ PJ_DECL(pj_status_t) pj_sock_socket(int family,
* @return Zero on success.
*/
PJ_DECL(pj_status_t) pj_sock_close(pj_sock_t sockfd);
-
+
/**
* This function gives the socket sockfd the local address my_addr. my_addr is
@@ -539,8 +548,7 @@ PJ_DECL(pj_status_t) pj_sock_getsockname( pj_sock_t sockfd,
*
* @param sockfd The socket descriptor.
* @param level The level which to get the option from.
- * @param optname The option name, which will be passed uninterpreted
- * by the library.
+ * @param optname The option name.
* @param optval Identifies the buffer which the value will be
* returned.
* @param optlen Initially contains the length of the buffer, upon
@@ -549,8 +557,8 @@ PJ_DECL(pj_status_t) pj_sock_getsockname( pj_sock_t sockfd,
* @return Zero on success.
*/
PJ_DECL(pj_status_t) pj_sock_getsockopt( pj_sock_t sockfd,
- int level,
- int optname,
+ pj_uint16_t level,
+ pj_uint16_t optname,
void *optval,
int *optlen);
/**
@@ -560,16 +568,15 @@ PJ_DECL(pj_status_t) pj_sock_getsockopt( pj_sock_t sockfd,
*
* @param sockfd The socket descriptor.
* @param level The level which to get the option from.
- * @param optname The option name, which will be passed uninterpreted
- * by the library.
+ * @param optname The option name.
* @param optval Identifies the buffer which contain the value.
* @param optlen The length of the value.
*
* @return PJ_SUCCESS or the status code.
*/
PJ_DECL(pj_status_t) pj_sock_setsockopt( pj_sock_t sockfd,
- int level,
- int optname,
+ pj_uint16_t level,
+ pj_uint16_t optname,
const void *optval,
int optlen);