os/graphics/graphicscomposition/openwfcompositionengine/adaptation/include/owfcond.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.
sl@0
     1
sl@0
     2
/* Copyright (c) 2009 The Khronos Group Inc.
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 OWFCOND_H_
sl@0
    25
#define OWFCOND_H_
sl@0
    26
sl@0
    27
#include "owftypes.h"
sl@0
    28
#include "owfmutex.h"
sl@0
    29
sl@0
    30
sl@0
    31
#ifdef __cplusplus
sl@0
    32
extern "C" {
sl@0
    33
#endif
sl@0
    34
sl@0
    35
sl@0
    36
typedef void* OWF_COND;
sl@0
    37
sl@0
    38
/*! \brief Initialize a condition variable
sl@0
    39
 *
sl@0
    40
 *  \param cond
sl@0
    41
 *  \param mutex mutex to be used when wait is called
sl@0
    42
 *
sl@0
    43
 *  \return true or false depending whether initialization
sl@0
    44
 *  succeeded or not
sl@0
    45
 */
sl@0
    46
OWF_API_CALL OWFboolean
sl@0
    47
OWF_Cond_Init(OWF_COND* cond, OWF_MUTEX mutex);
sl@0
    48
sl@0
    49
/*! \brief Destroy a condition variable
sl@0
    50
 *
sl@0
    51
 *  \cond cond variable
sl@0
    52
 */
sl@0
    53
OWF_API_CALL void
sl@0
    54
OWF_Cond_Destroy(OWF_COND* cond);
sl@0
    55
sl@0
    56
/*! \brief Block on a condition variable
sl@0
    57
 *
sl@0
    58
 *  \param cond
sl@0
    59
 *  \param timeout maximum time to wait in nanoseconds
sl@0
    60
 *
sl@0
    61
 * Cond must be initialized with OWF_Cond_Init. Caller MUST hold
sl@0
    62
 * the mutex specified upon initialization. Call will block on
sl@0
    63
 * the cond and release mutex until cond is signalled. After cond
sl@0
    64
 * is signalled the mutex is regained.
sl@0
    65
 *
sl@0
    66
 * The call will not block if timeout equals to zero. If timeout is
sl@0
    67
 * greater than zero, the call will not return until 'timeout'
sl@0
    68
 * nanoseconds has elapsed or cond is signalled. It timeout equal to
sl@0
    69
 * OWF_FOREVER, the call returns only after cond is signalled.
sl@0
    70
 */
sl@0
    71
OWF_API_CALL OWFboolean
sl@0
    72
OWF_Cond_Wait(OWF_COND cond, OWFtime timeout);
sl@0
    73
sl@0
    74
/*! \brief Signal a condition variable
sl@0
    75
 *
sl@0
    76
 *  \param cond
sl@0
    77
 *
sl@0
    78
 *  Only one of waiters for cond will be woke-up
sl@0
    79
 */
sl@0
    80
OWF_API_CALL OWFboolean
sl@0
    81
OWF_Cond_Signal(OWF_COND cond);
sl@0
    82
sl@0
    83
/*! \brief Signal a condition variable
sl@0
    84
 *
sl@0
    85
 *  \param cond
sl@0
    86
 *
sl@0
    87
 *  Wake-up all waiters of cond.
sl@0
    88
 */
sl@0
    89
OWF_API_CALL OWFboolean
sl@0
    90
OWF_Cond_SignalAll(OWF_COND cond);
sl@0
    91
sl@0
    92
sl@0
    93
#ifdef __cplusplus
sl@0
    94
}
sl@0
    95
#endif
sl@0
    96
sl@0
    97
sl@0
    98
sl@0
    99
#endif /* OWFCOND_H_ */