libsyncml  0.5.4
sml_queue_internals.h
1 /*
2  * libsyncml - A syncml protocol implementation
3  * Copyright (C) 2005 Armin Bauer <armin.bauer@opensync.org>
4  *
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.
9  *
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.
14  *
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
18  *
19  */
20 
28 
29 #ifndef _SML_QUEUE_INTERNALS_H_
30 #define _SML_QUEUE_INTERNALS_H_
31 
32 typedef void (*SmlQueueHandler)(void *message, void *userdata);
33 
36 typedef struct SmlQueue {
38  GList *head;
39  GList *tail;
40 
41  GList *prio;
43  SmlQueueHandler handler;
45  void *userdata;
47  GSource *source;
49  GMainContext *context;
50  GSourceFuncs *functions;
51  GMutex *mutex;
52 } SmlQueue;
53 
54 SmlQueue *smlQueueNew(SmlError **error);
55 void smlQueueFree(SmlQueue *queue);
56 void smlQueueFlush(SmlQueue *queue);
57 void smlQueueSetHandler(SmlQueue *queue, SmlQueueHandler handler, void *userdata);
58 void smlQueueSend(SmlQueue *queue, void *data);
59 void smlQueueAttach(SmlQueue *queue, GMainContext *context);
60 void smlQueueDetach(SmlQueue *queue);
61 void smlQueueDispatch(SmlQueue *queue);
62 void *smlQueueTryPop(SmlQueue *queue);
63 SmlBool smlQueueCheck(SmlQueue *queue);
64 void smlQueuePushHead(SmlQueue *queue, void *data);
65 SmlBool smlQueueIsAttached(SmlQueue *queue);
66 void smlQueueLock(SmlQueue *queue);
67 void smlQueueUnlock(SmlQueue *queue);
68 void *smlQueuePeek(SmlQueue *queue);
69 GList *smlQueuePeekNext(SmlQueue *queue, GList *prev);
70 void *smlQueueTryPopPrio(SmlQueue *queue);
71 void smlQueuePushHeadPrio(SmlQueue *queue, void *data);
72 void smlQueueSendPrio(SmlQueue *queue, void *data);
73 SmlBool smlQueueCheckPrio(SmlQueue *queue);
74 void smlQueueDispatchPrio(SmlQueue *queue);
75 void *smlQueuePeekPrio(SmlQueue *queue);
76 void smlQueuePrint(SmlQueue *queue);
77 unsigned int smlQueueLength(SmlQueue *queue);
78 unsigned int smlQueueLengthPrio(SmlQueue *queue);
79 
80 #endif //_SML_QUEUE_INTERNALS_H_
81 
SmlQueueHandler handler
struct SmlQueue SmlQueue
Represents a Queue which can be used to receive messages.
void smlQueueSend(SmlQueue *queue, void *data)
Sends a message down a queue.
Definition: sml_queue.c:353
void smlQueueSetHandler(SmlQueue *queue, SmlQueueHandler handler, void *userdata)
Sets the message handler for a queue.
Definition: sml_queue.c:384
SmlQueue * smlQueueNew(SmlError **error)
Creates a new asynchronous queue.
Definition: sml_queue.c:81
GSource * source
Represents a Queue which can be used to receive messages.
GMainContext * context
void smlQueueAttach(SmlQueue *queue, GMainContext *context)
Sets the queue to use the gmainloop with the given context.
Definition: sml_queue.c:400
Represent an error.
void smlQueueSendPrio(SmlQueue *queue, void *data)
Sends a message down a queue.
Definition: sml_queue.c:323