os/graphics/graphicscomposition/openwfcompositionengine/adaptation/include/owfcond.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/graphicscomposition/openwfcompositionengine/adaptation/include/owfcond.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,99 @@
     1.4 +
     1.5 +/* Copyright (c) 2009 The Khronos Group Inc.
     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 OWFCOND_H_
    1.28 +#define OWFCOND_H_
    1.29 +
    1.30 +#include "owftypes.h"
    1.31 +#include "owfmutex.h"
    1.32 +
    1.33 +
    1.34 +#ifdef __cplusplus
    1.35 +extern "C" {
    1.36 +#endif
    1.37 +
    1.38 +
    1.39 +typedef void* OWF_COND;
    1.40 +
    1.41 +/*! \brief Initialize a condition variable
    1.42 + *
    1.43 + *  \param cond
    1.44 + *  \param mutex mutex to be used when wait is called
    1.45 + *
    1.46 + *  \return true or false depending whether initialization
    1.47 + *  succeeded or not
    1.48 + */
    1.49 +OWF_API_CALL OWFboolean
    1.50 +OWF_Cond_Init(OWF_COND* cond, OWF_MUTEX mutex);
    1.51 +
    1.52 +/*! \brief Destroy a condition variable
    1.53 + *
    1.54 + *  \cond cond variable
    1.55 + */
    1.56 +OWF_API_CALL void
    1.57 +OWF_Cond_Destroy(OWF_COND* cond);
    1.58 +
    1.59 +/*! \brief Block on a condition variable
    1.60 + *
    1.61 + *  \param cond
    1.62 + *  \param timeout maximum time to wait in nanoseconds
    1.63 + *
    1.64 + * Cond must be initialized with OWF_Cond_Init. Caller MUST hold
    1.65 + * the mutex specified upon initialization. Call will block on
    1.66 + * the cond and release mutex until cond is signalled. After cond
    1.67 + * is signalled the mutex is regained.
    1.68 + *
    1.69 + * The call will not block if timeout equals to zero. If timeout is
    1.70 + * greater than zero, the call will not return until 'timeout'
    1.71 + * nanoseconds has elapsed or cond is signalled. It timeout equal to
    1.72 + * OWF_FOREVER, the call returns only after cond is signalled.
    1.73 + */
    1.74 +OWF_API_CALL OWFboolean
    1.75 +OWF_Cond_Wait(OWF_COND cond, OWFtime timeout);
    1.76 +
    1.77 +/*! \brief Signal a condition variable
    1.78 + *
    1.79 + *  \param cond
    1.80 + *
    1.81 + *  Only one of waiters for cond will be woke-up
    1.82 + */
    1.83 +OWF_API_CALL OWFboolean
    1.84 +OWF_Cond_Signal(OWF_COND cond);
    1.85 +
    1.86 +/*! \brief Signal a condition variable
    1.87 + *
    1.88 + *  \param cond
    1.89 + *
    1.90 + *  Wake-up all waiters of cond.
    1.91 + */
    1.92 +OWF_API_CALL OWFboolean
    1.93 +OWF_Cond_SignalAll(OWF_COND cond);
    1.94 +
    1.95 +
    1.96 +#ifdef __cplusplus
    1.97 +}
    1.98 +#endif
    1.99 +
   1.100 +
   1.101 +
   1.102 +#endif /* OWFCOND_H_ */