sl@0
|
1 |
/* Copyright (c) 2009 The Khronos Group Inc.
|
sl@0
|
2 |
* Portions copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies)
|
sl@0
|
3 |
*
|
sl@0
|
4 |
* Permission is hereby granted, free of charge, to any person obtaining a
|
sl@0
|
5 |
* copy of this software and/or associated documentation files (the
|
sl@0
|
6 |
* "Materials"), to deal in the Materials without restriction, including
|
sl@0
|
7 |
* without limitation the rights to use, copy, modify, merge, publish,
|
sl@0
|
8 |
* distribute, sublicense, and/or sell copies of the Materials, and to
|
sl@0
|
9 |
* permit persons to whom the Materials are furnished to do so, subject to
|
sl@0
|
10 |
* the following conditions:
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* The above copyright notice and this permission notice shall be included
|
sl@0
|
13 |
* in all copies or substantial portions of the Materials.
|
sl@0
|
14 |
*
|
sl@0
|
15 |
* THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
sl@0
|
16 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
sl@0
|
17 |
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
sl@0
|
18 |
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
sl@0
|
19 |
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
sl@0
|
20 |
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
sl@0
|
21 |
* MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
sl@0
|
22 |
*/
|
sl@0
|
23 |
|
sl@0
|
24 |
#ifndef OWF_MESSAGEQUEUE_H_
|
sl@0
|
25 |
#define OWF_MESSAGEQUEUE_H_
|
sl@0
|
26 |
|
sl@0
|
27 |
#include "owftypes.h"
|
sl@0
|
28 |
#include "owfsemaphore.h"
|
sl@0
|
29 |
#include "owfmutex.h"
|
sl@0
|
30 |
|
sl@0
|
31 |
|
sl@0
|
32 |
#ifdef __cplusplus
|
sl@0
|
33 |
extern "C" {
|
sl@0
|
34 |
#endif
|
sl@0
|
35 |
|
sl@0
|
36 |
#define WAIT_FOREVER -1
|
sl@0
|
37 |
#define MSG_QUEUE_WAIT_MSG_FETCHED 0
|
sl@0
|
38 |
#define MSG_QUEUE_WAIT_MSG_ERR -1
|
sl@0
|
39 |
#define MSG_QUEUE_WAIT_MSG_TIMEDOUT -2
|
sl@0
|
40 |
#define MSG_QUEUE_INIT_OK 0
|
sl@0
|
41 |
#define MSG_QUEUE_INIT_ERR -1
|
sl@0
|
42 |
|
sl@0
|
43 |
|
sl@0
|
44 |
typedef struct {
|
sl@0
|
45 |
OWFuint id;
|
sl@0
|
46 |
void* data;
|
sl@0
|
47 |
} OWF_MESSAGE;
|
sl@0
|
48 |
|
sl@0
|
49 |
typedef struct _MSGQUE {
|
sl@0
|
50 |
void* queuePtr;
|
sl@0
|
51 |
} OWF_MESSAGE_QUEUE;
|
sl@0
|
52 |
|
sl@0
|
53 |
/*
|
sl@0
|
54 |
* Destroy message queue
|
sl@0
|
55 |
*
|
sl@0
|
56 |
* \param queue Message queue to destroy
|
sl@0
|
57 |
*/
|
sl@0
|
58 |
OWF_API_CALL void
|
sl@0
|
59 |
OWF_MessageQueue_Destroy(OWF_MESSAGE_QUEUE* queue);
|
sl@0
|
60 |
|
sl@0
|
61 |
/*
|
sl@0
|
62 |
* Initialize message queue
|
sl@0
|
63 |
*
|
sl@0
|
64 |
* \param queue Message queue to initialize
|
sl@0
|
65 |
* \return 0 if initialization succeeded, < 0 otherwise
|
sl@0
|
66 |
*
|
sl@0
|
67 |
*/
|
sl@0
|
68 |
OWF_API_CALL OWFint
|
sl@0
|
69 |
OWF_MessageQueue_Init(OWF_MESSAGE_QUEUE* queue);
|
sl@0
|
70 |
|
sl@0
|
71 |
/*
|
sl@0
|
72 |
* Insert message into message queue (send it to
|
sl@0
|
73 |
* THE other side)
|
sl@0
|
74 |
*
|
sl@0
|
75 |
* \param queue Message queue
|
sl@0
|
76 |
* \param msg Message to send
|
sl@0
|
77 |
* \param data Message contents
|
sl@0
|
78 |
*
|
sl@0
|
79 |
*/
|
sl@0
|
80 |
OWF_API_CALL void
|
sl@0
|
81 |
OWF_Message_Send(OWF_MESSAGE_QUEUE* queue,
|
sl@0
|
82 |
OWFuint msg,
|
sl@0
|
83 |
void* data);
|
sl@0
|
84 |
/*
|
sl@0
|
85 |
* Wait for message
|
sl@0
|
86 |
*
|
sl@0
|
87 |
* \param queue Message queue
|
sl@0
|
88 |
* \param msg Where to store the received message
|
sl@0
|
89 |
* \param timeout Time to wait for the message (microseconds)
|
sl@0
|
90 |
*
|
sl@0
|
91 |
* \return < 0 if error occurred, 0 if no message was received within
|
sl@0
|
92 |
* given period of time, > 0 otherwise; received message is stored into
|
sl@0
|
93 |
* OWF_MESSAGE structure pointed by the msg param
|
sl@0
|
94 |
*
|
sl@0
|
95 |
*/
|
sl@0
|
96 |
OWF_API_CALL OWFint
|
sl@0
|
97 |
OWF_Message_Wait(OWF_MESSAGE_QUEUE* queue,
|
sl@0
|
98 |
OWF_MESSAGE* msg,
|
sl@0
|
99 |
OWFint timeout);
|
sl@0
|
100 |
|
sl@0
|
101 |
|
sl@0
|
102 |
#ifdef __cplusplus
|
sl@0
|
103 |
}
|
sl@0
|
104 |
#endif
|
sl@0
|
105 |
|
sl@0
|
106 |
|
sl@0
|
107 |
#endif
|