BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB Reference

ioqueue.h
Go to the documentation of this file.
1 /* $Id: ioqueue.h 4724 2014-01-31 08:52:09Z nanang $
2  */
3 /*
4  * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
5  * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  */
21 #ifndef __PJ_IOQUEUE_H__
22 #define __PJ_IOQUEUE_H__
23 
29 #include <pj/types.h>
30 
32 
209 typedef struct pj_ioqueue_op_key_t
210 {
211  void *internal__[32];
213  void *user_data;
215 
220 typedef struct pj_ioqueue_callback
221 {
235  pj_ssize_t bytes_read);
236 
250  pj_ssize_t bytes_sent);
251 
262  pj_sock_t sock,
263  pj_status_t status);
264 
272  pj_status_t status);
274 
275 
281 {
289 #if defined(PJ_HAS_TCP) && PJ_HAS_TCP != 0
292 #endif /* PJ_HAS_TCP */
294 
295 
302 #ifndef PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL
303 # define PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL (16)
304 #endif
305 
310 #define PJ_IOQUEUE_ALWAYS_ASYNC ((pj_uint32_t)1 << (pj_uint32_t)31)
311 
317 PJ_DECL(const char*) pj_ioqueue_name(void);
318 
319 
330 PJ_DECL(pj_status_t) pj_ioqueue_create( pj_pool_t *pool,
331  pj_size_t max_fd,
332  pj_ioqueue_t **ioqueue);
333 
341 PJ_DECL(pj_status_t) pj_ioqueue_destroy( pj_ioqueue_t *ioque );
342 
359  pj_lock_t *lock,
360  pj_bool_t auto_delete );
361 
378  pj_bool_t allow);
379 
401  pj_ioqueue_t *ioque,
402  pj_sock_t sock,
403  void *user_data,
404  const pj_ioqueue_callback *cb,
405  pj_ioqueue_key_t **key );
406 
413  pj_ioqueue_t *ioque,
414  pj_sock_t sock,
415  pj_grp_lock_t *grp_lock,
416  void *user_data,
417  const pj_ioqueue_callback *cb,
418  pj_ioqueue_key_t **key );
419 
442 
443 
453 PJ_DECL(void*) pj_ioqueue_get_user_data( pj_ioqueue_key_t *key );
454 
466  void *user_data,
467  void **old_data);
468 
492  pj_bool_t allow);
493 
505 
514 
522  pj_size_t size );
523 
537  pj_ioqueue_op_key_t *op_key );
538 
539 
555  pj_ioqueue_op_key_t *op_key,
556  pj_ssize_t bytes_status );
557 
558 
559 
560 #if defined(PJ_HAS_TCP) && PJ_HAS_TCP != 0
561 
594  pj_ioqueue_op_key_t *op_key,
595  pj_sock_t *new_sock,
596  pj_sockaddr_t *local,
597  pj_sockaddr_t *remote,
598  int *addrlen );
599 
618  const pj_sockaddr_t *addr,
619  int addrlen );
620 
621 #endif /* PJ_HAS_TCP */
622 
638 PJ_DECL(int) pj_ioqueue_poll( pj_ioqueue_t *ioque,
639  const pj_time_val *timeout);
640 
641 
678  pj_ioqueue_op_key_t *op_key,
679  void *buffer,
680  pj_ssize_t *length,
681  pj_uint32_t flags );
682 
721  pj_ioqueue_op_key_t *op_key,
722  void *buffer,
723  pj_ssize_t *length,
724  pj_uint32_t flags,
725  pj_sockaddr_t *addr,
726  int *addrlen);
727 
763  pj_ioqueue_op_key_t *op_key,
764  const void *data,
765  pj_ssize_t *length,
766  pj_uint32_t flags );
767 
768 
803  pj_ioqueue_op_key_t *op_key,
804  const void *data,
805  pj_ssize_t *length,
806  pj_uint32_t flags,
807  const pj_sockaddr_t *addr,
808  int addrlen);
809 
810 
816 
817 #endif /* __PJ_IOQUEUE_H__ */
818 
pj_status_t pj_ioqueue_unlock_key(pj_ioqueue_key_t *key)
pj_status_t pj_ioqueue_register_sock2(pj_pool_t *pool, pj_ioqueue_t *ioque, pj_sock_t sock, pj_grp_lock_t *grp_lock, void *user_data, const pj_ioqueue_callback *cb, pj_ioqueue_key_t **key)
Definition: ioqueue.h:285
pj_status_t pj_ioqueue_destroy(pj_ioqueue_t *ioque)
int pj_ioqueue_poll(pj_ioqueue_t *ioque, const pj_time_val *timeout)
Definition: ioqueue.h:291
pj_status_t pj_ioqueue_set_user_data(pj_ioqueue_key_t *key, void *user_data, void **old_data)
pj_status_t pj_ioqueue_connect(pj_ioqueue_key_t *key, const pj_sockaddr_t *addr, int addrlen)
int pj_bool_t
Definition: types.h:71
void * internal__[32]
Definition: ioqueue.h:211
void * user_data
Definition: ioqueue.h:213
void(* on_connect_complete)(pj_ioqueue_key_t *key, pj_status_t status)
Definition: ioqueue.h:271
pj_bool_t pj_ioqueue_is_pending(pj_ioqueue_key_t *key, pj_ioqueue_op_key_t *op_key)
Definition: ioqueue.h:287
Definition: types.h:382
pj_status_t pj_ioqueue_unregister(pj_ioqueue_key_t *key)
pj_status_t pj_ioqueue_create(pj_pool_t *pool, pj_size_t max_fd, pj_ioqueue_t **ioqueue)
Definition: ioqueue.h:220
void pj_ioqueue_op_key_init(pj_ioqueue_op_key_t *op_key, pj_size_t size)
pj_status_t pj_ioqueue_recvfrom(pj_ioqueue_key_t *key, pj_ioqueue_op_key_t *op_key, void *buffer, pj_ssize_t *length, pj_uint32_t flags, pj_sockaddr_t *addr, int *addrlen)
void(* on_read_complete)(pj_ioqueue_key_t *key, pj_ioqueue_op_key_t *op_key, pj_ssize_t bytes_read)
Definition: ioqueue.h:233
Declaration of basic types and utility.
pj_status_t pj_ioqueue_set_concurrency(pj_ioqueue_key_t *key, pj_bool_t allow)
pj_status_t pj_ioqueue_send(pj_ioqueue_key_t *key, pj_ioqueue_op_key_t *op_key, const void *data, pj_ssize_t *length, pj_uint32_t flags)
Definition: ioqueue.h:290
int pj_status_t
Definition: types.h:68
pj_status_t pj_ioqueue_sendto(pj_ioqueue_key_t *key, pj_ioqueue_op_key_t *op_key, const void *data, pj_ssize_t *length, pj_uint32_t flags, const pj_sockaddr_t *addr, int addrlen)
void(* on_accept_complete)(pj_ioqueue_key_t *key, pj_ioqueue_op_key_t *op_key, pj_sock_t sock, pj_status_t status)
Definition: ioqueue.h:260
Definition: ioqueue.h:209
pj_status_t pj_ioqueue_accept(pj_ioqueue_key_t *key, pj_ioqueue_op_key_t *op_key, pj_sock_t *new_sock, pj_sockaddr_t *local, pj_sockaddr_t *remote, int *addrlen)
void pj_sockaddr_t
Definition: types.h:267
Definition: udp_echo_srv_ioqueue.c:27
struct pj_grp_lock_t pj_grp_lock_t
Definition: types.h:242
pj_status_t pj_ioqueue_recv(pj_ioqueue_key_t *key, pj_ioqueue_op_key_t *op_key, void *buffer, pj_ssize_t *length, pj_uint32_t flags)
struct pj_ioqueue_t pj_ioqueue_t
Definition: types.h:210
unsigned int pj_uint32_t
Definition: types.h:43
struct pj_lock_t pj_lock_t
Definition: types.h:239
void(* on_write_complete)(pj_ioqueue_key_t *key, pj_ioqueue_op_key_t *op_key, pj_ssize_t bytes_sent)
Definition: ioqueue.h:248
#define PJ_END_DECL
Definition: config.h:1067
pj_status_t pj_ioqueue_register_sock(pj_pool_t *pool, pj_ioqueue_t *ioque, pj_sock_t sock, void *user_data, const pj_ioqueue_callback *cb, pj_ioqueue_key_t **key)
Definition: ioqueue.h:288
#define PJ_BEGIN_DECL
Definition: config.h:1066
long pj_sock_t
Definition: types.h:263
pj_ioqueue_operation_e
Definition: ioqueue.h:280
pj_status_t pj_ioqueue_set_default_concurrency(pj_ioqueue_t *ioqueue, pj_bool_t allow)
long pj_ssize_t
Definition: types.h:64
void * activesock_data
Definition: ioqueue.h:212
Definition: ioqueue.h:284
Definition: pool.h:313
pj_status_t pj_ioqueue_lock_key(pj_ioqueue_key_t *key)
Definition: ioqueue.h:286
Definition: ioqueue.h:282
pj_status_t pj_ioqueue_set_lock(pj_ioqueue_t *ioque, pj_lock_t *lock, pj_bool_t auto_delete)
struct pj_ioqueue_key_t pj_ioqueue_key_t
Definition: types.h:216
pj_status_t pj_ioqueue_post_completion(pj_ioqueue_key_t *key, pj_ioqueue_op_key_t *op_key, pj_ssize_t bytes_status)
Definition: ioqueue.h:283
void * pj_ioqueue_get_user_data(pj_ioqueue_key_t *key)
size_t pj_size_t
Definition: types.h:58
const char * pj_ioqueue_name(void)

 


PJLIB Open Source, high performance, small footprint, and very very portable framework
Copyright (C) 2006-2009 Teluu Inc.