ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/branches/newio/include/msgq.h
Revision: 2388
Committed: Tue Jul 9 11:22:52 2013 UTC (13 years, 3 months ago) by michael
Content type: text/x-chdr
File size: 2989 byte(s)
Log Message:
- Working towards implementing new ioengine

File Contents

# Content
1 /*
2 * ircd-hybrid: an advanced Internet Relay Chat Daemon(ircd).
3 *
4 * Copyright (C) 2000 Kevin L. Mitchell <klmitch@mit.edu>
5 * Copyright (C) 2013 by the Hybrid Development Team.
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
20 * USA
21 */
22
23 /*! \file msgq.h
24 * \brief Outbound message queue implementation.
25 * \version $Id: msgq.h 2386 2013-07-06 20:47:09Z michael $
26 */
27
28 #ifndef INCLUDED_msgq_h
29 #define INCLUDED_msgq_h
30
31 #ifndef INCLUDED_ircd_defs_h
32 #include "ircd_defs.h" /* BUFSIZE */
33 #endif
34 #ifndef INCLUDED_sys_types_h
35 #include <sys/types.h>
36 #define INCLUDED_sys_types_h
37 #endif
38 #ifndef INCLUDED_stdarg_h
39 #include <stdarg.h>
40 #define INCLUDED_stdarg_h
41 #endif
42
43 struct iovec;
44 struct Client;
45 struct Msg;
46 struct MsgBuf;
47
48 /** Queue of individual messages. */
49 struct MsgQList
50 {
51 struct Msg *head; /**< First Msg in queue list */
52 struct Msg *tail; /**< Last Msg in queue list */
53 };
54
55 /** Entire two-priority message queue for a destination. */
56 struct MsgQ
57 {
58 unsigned int length; /**< Current number of bytes stored */
59 unsigned int count; /**< Current number of messages stored */
60 struct MsgQList queue; /**< Normal Msg queue */
61 struct MsgQList prio; /**< Priority Msg queue */
62 };
63
64 /** Returns the current number of bytes stored in \a mq. */
65 #define MsgQLength(mq) ((mq)->length)
66
67 /** Returns the current number of messages stored in \a mq. */
68 #define MsgQCount(mq) ((mq)->count)
69
70 /** Scratch the current content of the buffer.
71 * Release all allocated buffers and make it empty.
72 */
73 #define MsgQClear(mq) msgq_delete((mq), MsgQLength(mq))
74
75 /*
76 * Prototypes
77 */
78 extern void msgq_init(struct MsgQ *);
79 extern void msgq_delete(struct MsgQ *, unsigned int);
80 extern int msgq_mapiov(const struct MsgQ *, struct iovec *, int, unsigned int *);
81 extern struct MsgBuf *msgq_make(struct Client *, const char *, ...);
82 extern struct MsgBuf *msgq_vmake(struct Client *, const char *, va_list);
83 extern void msgq_append(struct Client *, struct MsgBuf *, const char *, ...);
84 extern void msgq_clean(struct MsgBuf *);
85 extern void msgq_add(struct MsgQ *, struct MsgBuf *, int);
86 extern void msgq_count_memory(struct Client *, size_t *, size_t *);
87 extern void msgq_histogram(struct Client *);
88 extern unsigned int msgq_bufleft(struct MsgBuf *);
89 #endif /* INCLUDED_msgq_h */