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