BLOG | DOCUMENTATION | TRAC

Home --> Documentations --> PJLIB Reference

ioqueue.h
Go to the documentation of this file.
1 /* $Id: ioqueue.h 5194 2015-11-06 04:18:46Z 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 
249  pj_ioqueue_op_key_t *op_key,
250  pj_ssize_t bytes_sent);
251 
261  pj_ioqueue_op_key_t *op_key,
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 
306 
321 #if !defined(PJ_IOQUEUE_MAX_CAND_EVENTS) || \
322  PJ_IOQUEUE_MAX_CAND_EVENTS < PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL
323 # undef PJ_IOQUEUE_MAX_CAND_EVENTS
324 # define PJ_IOQUEUE_MAX_CAND_EVENTS PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL
325 #endif
326 
327 
332 #define PJ_IOQUEUE_ALWAYS_ASYNC ((pj_uint32_t)1 << (pj_uint32_t)31)
333 
339 PJ_DECL(const char*) pj_ioqueue_name(void);
340 
341 
352 PJ_DECL(pj_status_t) pj_ioqueue_create( pj_pool_t *pool,
353  pj_size_t max_fd,
354  pj_ioqueue_t **ioqueue);
355 
363 PJ_DECL(pj_status_t) pj_ioqueue_destroy( pj_ioqueue_t *ioque );
364 
381  pj_lock_t *lock,
382  pj_bool_t auto_delete );
383 
400  pj_bool_t allow);
401 
423  pj_ioqueue_t *ioque,
424  pj_sock_t sock,
425  void *user_data,
426  const pj_ioqueue_callback *cb,
427  pj_ioqueue_key_t **key );
428 
435  pj_ioqueue_t *ioque,
436  pj_sock_t sock,
437  pj_grp_lock_t *grp_lock,
438  void *user_data,
439  const pj_ioqueue_callback *cb,
440  pj_ioqueue_key_t **key );
441 
464 
465 
475 PJ_DECL(void*) pj_ioqueue_get_user_data( pj_ioqueue_key_t *key );
476 
488  void *user_data,
489  void **old_data);
490 
514  pj_bool_t allow);
515 
527 
538 
547 
555  pj_size_t size );
556 
570  pj_ioqueue_op_key_t *op_key );
571 
572 
588  pj_ioqueue_op_key_t *op_key,
589  pj_ssize_t bytes_status );
590 
591 
592 
593 #if defined(PJ_HAS_TCP) && PJ_HAS_TCP != 0
594 
627  pj_ioqueue_op_key_t *op_key,
628  pj_sock_t *new_sock,
629  pj_sockaddr_t *local,
630  pj_sockaddr_t *remote,
631  int *addrlen );
632 
651  const pj_sockaddr_t *addr,
652  int addrlen );
653 
654 #endif /* PJ_HAS_TCP */
655 
671 PJ_DECL(int) pj_ioqueue_poll( pj_ioqueue_t *ioque,
672  const pj_time_val *timeout);
673 
674 
711  pj_ioqueue_op_key_t *op_key,
712  void *buffer,
713  pj_ssize_t *length,
714  pj_uint32_t flags );
715 
754  pj_ioqueue_op_key_t *op_key,
755  void *buffer,
756  pj_ssize_t *length,
757  pj_uint32_t flags,
758  pj_sockaddr_t *addr,
759  int *addrlen);
760 
796  pj_ioqueue_op_key_t *op_key,
797  const void *data,
798  pj_ssize_t *length,
799  pj_uint32_t flags );
800 
801 
836  pj_ioqueue_op_key_t *op_key,
837  const void *data,
838  pj_ssize_t *length,
839  pj_uint32_t flags,
840  const pj_sockaddr_t *addr,
841  int addrlen);
842 
843 
849 
850 #endif /* __PJ_IOQUEUE_H__ */
851 
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
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)
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
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
pj_status_t pj_ioqueue_create(pj_pool_t *pool, pj_size_t max_fd, pj_ioqueue_t **ioqueue)
Definition: ioqueue.h:220
pj_status_t pj_ioqueue_trylock_key(pj_ioqueue_key_t *key)
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)
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)
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
#define PJ_END_DECL
Definition: config.h:1096
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
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_BEGIN_DECL
Definition: config.h:1095
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)
void(* on_connect_complete)(pj_ioqueue_key_t *key, pj_status_t status)
Definition: ioqueue.h:271
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.