BLOG | DOCUMENTATION | GITHUB

Home --> Documentations --> PJLIB Reference

ioqueue.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
3 * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19#ifndef __PJ_IOQUEUE_H__
20#define __PJ_IOQUEUE_H__
21
27#include <pj/types.h>
28
30
208{
209 void *internal__[32];
211 void *user_data;
213
219{
233 pj_ssize_t bytes_read);
234
248 pj_ssize_t bytes_sent);
249
260 pj_sock_t sock,
261 pj_status_t status);
262
270 pj_status_t status);
272
273
279{
287#if defined(PJ_HAS_TCP) && PJ_HAS_TCP != 0
290#endif /* PJ_HAS_TCP */
292
293
300#ifndef PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL
301# define PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL (16)
302#endif
303
304
319#if !defined(PJ_IOQUEUE_MAX_CAND_EVENTS) || \
320 PJ_IOQUEUE_MAX_CAND_EVENTS < PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL
321# undef PJ_IOQUEUE_MAX_CAND_EVENTS
322# define PJ_IOQUEUE_MAX_CAND_EVENTS PJ_IOQUEUE_MAX_EVENTS_IN_SINGLE_POLL
323#endif
324
325
330#define PJ_IOQUEUE_ALWAYS_ASYNC ((pj_uint32_t)1 << (pj_uint32_t)31)
331
332
337{
341
345
353
355
356
361typedef struct pj_ioqueue_cfg
362{
370 unsigned epoll_flags;
371
380
382
383
390
391
397PJ_DECL(const char*) pj_ioqueue_name(void);
398
399
411 pj_size_t max_fd,
412 pj_ioqueue_t **ioqueue);
413
429 pj_size_t max_fd,
430 const pj_ioqueue_cfg *cfg,
431 pj_ioqueue_t **ioqueue);
432
441
458 pj_lock_t *lock,
459 pj_bool_t auto_delete );
460
477 pj_bool_t allow);
478
500 pj_ioqueue_t *ioque,
501 pj_sock_t sock,
502 void *user_data,
503 const pj_ioqueue_callback *cb,
504 pj_ioqueue_key_t **key );
505
512 pj_ioqueue_t *ioque,
513 pj_sock_t sock,
514 pj_grp_lock_t *grp_lock,
515 void *user_data,
516 const pj_ioqueue_callback *cb,
517 pj_ioqueue_key_t **key );
518
541
542
553
565 void *user_data,
566 void **old_data);
567
591 pj_bool_t allow);
592
604
615
624
632 pj_size_t size );
633
648
649
666 pj_ssize_t bytes_status );
667
668
680
681
682
683#if defined(PJ_HAS_TCP) && PJ_HAS_TCP != 0
718 pj_sock_t *new_sock,
719 pj_sockaddr_t *local,
720 pj_sockaddr_t *remote,
721 int *addrlen );
722
741 const pj_sockaddr_t *addr,
742 int addrlen );
743
744#endif /* PJ_HAS_TCP */
745
761PJ_DECL(int) pj_ioqueue_poll( pj_ioqueue_t *ioque,
762 const pj_time_val *timeout);
763
764
802 void *buffer,
803 pj_ssize_t *length,
804 pj_uint32_t flags );
805
845 void *buffer,
846 pj_ssize_t *length,
847 pj_uint32_t flags,
848 pj_sockaddr_t *addr,
849 int *addrlen);
850
887 const void *data,
888 pj_ssize_t *length,
889 pj_uint32_t flags );
890
891
927 const void *data,
928 pj_ssize_t *length,
929 pj_uint32_t flags,
930 const pj_sockaddr_t *addr,
931 int addrlen);
932
933
939
940#endif /* __PJ_IOQUEUE_H__ */
941
long pj_ssize_t
Definition: types.h:64
int pj_bool_t
Definition: types.h:71
struct pj_ioqueue_t pj_ioqueue_t
Definition: types.h:210
struct pj_lock_t pj_lock_t
Definition: types.h:239
long pj_sock_t
Definition: types.h:263
struct pj_ioqueue_key_t pj_ioqueue_key_t
Definition: types.h:216
size_t pj_size_t
Definition: types.h:58
void pj_sockaddr_t
Definition: types.h:267
int pj_status_t
Definition: types.h:68
struct pj_grp_lock_t pj_grp_lock_t
Definition: types.h:242
unsigned int pj_uint32_t
Definition: types.h:43
pj_ioqueue_epoll_flag
Definition: ioqueue.h:337
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)
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)
pj_status_t pj_ioqueue_create2(pj_pool_t *pool, pj_size_t max_fd, const pj_ioqueue_cfg *cfg, pj_ioqueue_t **ioqueue)
pj_status_t pj_ioqueue_set_user_data(pj_ioqueue_key_t *key, void *user_data, void **old_data)
pj_status_t pj_ioqueue_destroy(pj_ioqueue_t *ioque)
pj_status_t pj_ioqueue_set_default_concurrency(pj_ioqueue_t *ioqueue, pj_bool_t allow)
pj_ioqueue_operation_e
Definition: ioqueue.h:279
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)
void * pj_ioqueue_get_user_data(pj_ioqueue_key_t *key)
pj_bool_t pj_ioqueue_is_pending(pj_ioqueue_key_t *key, pj_ioqueue_op_key_t *op_key)
pj_status_t pj_ioqueue_unregister(pj_ioqueue_key_t *key)
void pj_ioqueue_cfg_default(pj_ioqueue_cfg *cfg)
pj_status_t pj_ioqueue_set_lock(pj_ioqueue_t *ioque, pj_lock_t *lock, pj_bool_t auto_delete)
pj_status_t pj_ioqueue_unlock_key(pj_ioqueue_key_t *key)
pj_status_t pj_ioqueue_create(pj_pool_t *pool, pj_size_t max_fd, pj_ioqueue_t **ioqueue)
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)
int pj_ioqueue_poll(pj_ioqueue_t *ioque, const pj_time_val *timeout)
pj_status_t pj_ioqueue_set_concurrency(pj_ioqueue_key_t *key, pj_bool_t allow)
pj_status_t pj_ioqueue_post_completion(pj_ioqueue_key_t *key, pj_ioqueue_op_key_t *op_key, pj_ssize_t bytes_status)
pj_status_t pj_ioqueue_lock_key(pj_ioqueue_key_t *key)
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)
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)
pj_status_t pj_ioqueue_clear_key(pj_ioqueue_key_t *key)
pj_status_t pj_ioqueue_trylock_key(pj_ioqueue_key_t *key)
const char * pj_ioqueue_name(void)
pj_status_t pj_ioqueue_connect(pj_ioqueue_key_t *key, const pj_sockaddr_t *addr, int addrlen)
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)
@ PJ_IOQUEUE_EPOLL_AUTO
Definition: ioqueue.h:351
@ PJ_IOQUEUE_EPOLL_ONESHOT
Definition: ioqueue.h:344
@ PJ_IOQUEUE_EPOLL_EXCLUSIVE
Definition: ioqueue.h:340
@ PJ_IOQUEUE_OP_SEND_TO
Definition: ioqueue.h:286
@ PJ_IOQUEUE_OP_RECV
Definition: ioqueue.h:282
@ PJ_IOQUEUE_OP_RECV_FROM
Definition: ioqueue.h:283
@ PJ_IOQUEUE_OP_READ
Definition: ioqueue.h:281
@ PJ_IOQUEUE_OP_WRITE
Definition: ioqueue.h:284
@ PJ_IOQUEUE_OP_SEND
Definition: ioqueue.h:285
@ PJ_IOQUEUE_OP_ACCEPT
Definition: ioqueue.h:288
@ PJ_IOQUEUE_OP_CONNECT
Definition: ioqueue.h:289
@ PJ_IOQUEUE_OP_NONE
Definition: ioqueue.h:280
#define PJ_BEGIN_DECL
Definition: config.h:1284
#define PJ_END_DECL
Definition: config.h:1285
Definition: udp_echo_srv_ioqueue.c:27
Definition: ioqueue.h:219
void(* on_write_complete)(pj_ioqueue_key_t *key, pj_ioqueue_op_key_t *op_key, pj_ssize_t bytes_sent)
Definition: ioqueue.h:246
void(* on_read_complete)(pj_ioqueue_key_t *key, pj_ioqueue_op_key_t *op_key, pj_ssize_t bytes_read)
Definition: ioqueue.h:231
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:258
void(* on_connect_complete)(pj_ioqueue_key_t *key, pj_status_t status)
Definition: ioqueue.h:269
Definition: ioqueue.h:362
unsigned epoll_flags
Definition: ioqueue.h:370
pj_bool_t default_concurrency
Definition: ioqueue.h:379
Definition: ioqueue.h:208
void * activesock_data
Definition: ioqueue.h:210
void * user_data
Definition: ioqueue.h:211
void * internal__[32]
Definition: ioqueue.h:209
Definition: pool.h:310
Definition: types.h:397
Declaration of basic types and utility.

 


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