2 * libopensync - A synchronization framework
3 * Copyright (C) 2004-2005 Armin Bauer <armin.bauer@opensync.org>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library 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 GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #ifndef _OPENSYNC_QUEUE_PRIVATE_H
22 #define _OPENSYNC_QUEUE_PRIVATE_H
33 * @defgroup OSyncQueuePrivateAPI OpenSync Queue Private
34 * @ingroup OSyncIPCPrivate
35 * @brief A Queue used for asynchronous communication between thread
40 /*! @brief Represents a Queue which can be used to receive messages
43 /** The queue type **/
46 /** The real asynchronous queue from glib **/
49 /** The path name of this queue **/
52 /** The message handler for this queue **/
53 OSyncMessageHandler message_handler
;
55 /** The user_data associated with this queue **/
58 /** The source associated with this queue */
59 GSourceFuncs
*incoming_functions
;
60 GSource
*incoming_source
;
62 /** The context in which the IO of the queue is dispatched */
63 GMainContext
*context
;
64 GMainContext
*incomingContext
;
68 GAsyncQueue
*incoming
;
69 GAsyncQueue
*outgoing
;
71 /** List of pending replies */
72 OSyncList
*pendingReplies
;
74 unsigned int pendingCount
, pendingLimit
;
76 GSourceFuncs
*write_functions
;
77 GSource
*write_source
;
79 GSourceFuncs
*read_functions
;
82 /** Timeout Source **/
83 GSourceFuncs
*timeout_functions
;
84 GSource
*timeout_source
;
86 GMutex
*disconnectLock
;
88 /** Connection status **/
91 /** Reference count **/
94 /* Queue for replies to incoming messages */
95 OSyncQueue
*reply_queue
;
97 /* Queue for receiving commands we are replying to */
98 OSyncQueue
*cmd_queue
;
100 /* Disconnect in progress */
101 gboolean disc_in_progress
;
103 /* Largest timeout value seen so far */
104 unsigned int max_timeout
;
106 /* Expiration time of pending queue timeout */
107 GTimeVal pending_timeout
;
110 /** @brief Pending queue timeout addition for ipc delay
112 #define OSYNC_QUEUE_PENDING_QUEUE_IPC_DELAY 1
114 /** @brief Pending queue minimum timeout
116 #define OSYNC_QUEUE_PENDING_QUEUE_MIN_TIMEOUT 20
118 /** @brief Timeout object
120 typedef struct OSyncTimeoutInfo
{
121 /** Expiration date */
125 /** @brief Pending Message object
127 typedef struct OSyncPendingMessage
{
128 /** ID of the expected Message */
130 /** Where should the reply be received? */
131 OSyncMessageHandler callback
;
134 /** Message Timeout */
135 OSyncTimeoutInfo
*timeout_info
;
136 } OSyncPendingMessage
;
139 * @brief Generate IDs
140 * Ids are generated as follows:
142 * the upper 6 bytes are the time in seconds and microseconds
143 * the lower 2 bytes are a random number
146 static long long int opensync_queue_gen_id(const GTimeVal
*tv
);
150 #endif /* _OPENSYNC_QUEUE_PRIVATE_H */