os/graphics/graphicscomposition/openwfcompositionengine/adaptation/include/owfmessagequeue.h
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/graphics/graphicscomposition/openwfcompositionengine/adaptation/include/owfmessagequeue.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,107 @@
1.4 +/* Copyright (c) 2009 The Khronos Group Inc.
1.5 + * Portions copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies)
1.6 + *
1.7 + * Permission is hereby granted, free of charge, to any person obtaining a
1.8 + * copy of this software and/or associated documentation files (the
1.9 + * "Materials"), to deal in the Materials without restriction, including
1.10 + * without limitation the rights to use, copy, modify, merge, publish,
1.11 + * distribute, sublicense, and/or sell copies of the Materials, and to
1.12 + * permit persons to whom the Materials are furnished to do so, subject to
1.13 + * the following conditions:
1.14 + *
1.15 + * The above copyright notice and this permission notice shall be included
1.16 + * in all copies or substantial portions of the Materials.
1.17 + *
1.18 + * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
1.19 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
1.20 + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
1.21 + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
1.22 + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
1.23 + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1.24 + * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
1.25 + */
1.26 +
1.27 +#ifndef OWF_MESSAGEQUEUE_H_
1.28 +#define OWF_MESSAGEQUEUE_H_
1.29 +
1.30 +#include "owftypes.h"
1.31 +#include "owfsemaphore.h"
1.32 +#include "owfmutex.h"
1.33 +
1.34 +
1.35 +#ifdef __cplusplus
1.36 +extern "C" {
1.37 +#endif
1.38 +
1.39 +#define WAIT_FOREVER -1
1.40 +#define MSG_QUEUE_WAIT_MSG_FETCHED 0
1.41 +#define MSG_QUEUE_WAIT_MSG_ERR -1
1.42 +#define MSG_QUEUE_WAIT_MSG_TIMEDOUT -2
1.43 +#define MSG_QUEUE_INIT_OK 0
1.44 +#define MSG_QUEUE_INIT_ERR -1
1.45 +
1.46 +
1.47 +typedef struct {
1.48 + OWFuint id;
1.49 + void* data;
1.50 +} OWF_MESSAGE;
1.51 +
1.52 +typedef struct _MSGQUE {
1.53 + void* queuePtr;
1.54 +} OWF_MESSAGE_QUEUE;
1.55 +
1.56 +/*
1.57 + * Destroy message queue
1.58 + *
1.59 + * \param queue Message queue to destroy
1.60 + */
1.61 +OWF_API_CALL void
1.62 +OWF_MessageQueue_Destroy(OWF_MESSAGE_QUEUE* queue);
1.63 +
1.64 +/*
1.65 + * Initialize message queue
1.66 + *
1.67 + * \param queue Message queue to initialize
1.68 + * \return 0 if initialization succeeded, < 0 otherwise
1.69 + *
1.70 + */
1.71 +OWF_API_CALL OWFint
1.72 +OWF_MessageQueue_Init(OWF_MESSAGE_QUEUE* queue);
1.73 +
1.74 +/*
1.75 + * Insert message into message queue (send it to
1.76 + * THE other side)
1.77 + *
1.78 + * \param queue Message queue
1.79 + * \param msg Message to send
1.80 + * \param data Message contents
1.81 + *
1.82 + */
1.83 +OWF_API_CALL void
1.84 +OWF_Message_Send(OWF_MESSAGE_QUEUE* queue,
1.85 + OWFuint msg,
1.86 + void* data);
1.87 +/*
1.88 + * Wait for message
1.89 + *
1.90 + * \param queue Message queue
1.91 + * \param msg Where to store the received message
1.92 + * \param timeout Time to wait for the message (microseconds)
1.93 + *
1.94 + * \return < 0 if error occurred, 0 if no message was received within
1.95 + * given period of time, > 0 otherwise; received message is stored into
1.96 + * OWF_MESSAGE structure pointed by the msg param
1.97 + *
1.98 + */
1.99 +OWF_API_CALL OWFint
1.100 +OWF_Message_Wait(OWF_MESSAGE_QUEUE* queue,
1.101 + OWF_MESSAGE* msg,
1.102 + OWFint timeout);
1.103 +
1.104 +
1.105 +#ifdef __cplusplus
1.106 +}
1.107 +#endif
1.108 +
1.109 +
1.110 +#endif