root/src/libsir/include/sir/condition.h

/* [previous][next][first][last][top][bottom][index][help] */

INCLUDED FROM


   1 /**
   2  * @file condition.h
   3  *
   4  * @version 2.2.5
   5  *
   6  * -----------------------------------------------------------------------------
   7  *
   8  * SPDX-License-Identifier: MIT
   9  *
  10  * Copyright (c) 2018-2024 Ryan M. Lederman <lederman@gmail.com>
  11  *
  12  * Permission is hereby granted, free of charge, to any person obtaining a copy of
  13  * this software and associated documentation files (the "Software"), to deal in
  14  * the Software without restriction, including without limitation the rights to
  15  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  16  * the Software, and to permit persons to whom the Software is furnished to do so,
  17  * subject to the following conditions:
  18  *
  19  * The above copyright notice and this permission notice shall be included in all
  20  * copies or substantial portions of the Software.
  21  *
  22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  24  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  25  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  26  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  27  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  28  *
  29  * -----------------------------------------------------------------------------
  30  */
  31 
  32 #ifndef _SIR_CONDITION_H_INCLUDED
  33 # define _SIR_CONDITION_H_INCLUDED
  34 
  35 # include "sir/types.h"
  36 
  37 /**
  38  * Creates/initializes a new condition variable.
  39  *
  40  * @param cond Pointer to a sir_condition to initialize
  41  * @returns bool `true` if successful, `false` otherwise.
  42  */
  43 bool _sir_condcreate(sir_condition* cond);
  44 
  45 
  46 
  47 
  48 
  49 
  50 
  51 
  52 
  53 
  54 
  55 /**
  56  * Broadcast signals a condition variable.
  57  *
  58  * @param cond Pointer to a sir_condition to broadcast on.
  59  * @returns bool `true` if successful, `false` otherwise.
  60  */
  61 bool _sir_condbroadcast(sir_condition* cond);
  62 
  63 /**
  64  * Destroys a condition variable.
  65  *
  66  * @param cond Pointer to a sir_condition to destroy.
  67  * @returns bool `true` if successful, `false` otherwise.
  68  */
  69 bool _sir_conddestroy(sir_condition* cond);
  70 
  71 
  72 
  73 
  74 
  75 
  76 
  77 
  78 
  79 
  80 
  81 /**
  82  * Waits a given amount of time for a condition variable to become signaled.
  83  *
  84  * @param cond Pointer to a sir_condition to wait on.
  85  * @param mutex Associated mutex object.
  86  * @param howlong How long to wait before timing out.
  87  * @returns bool `true` if successful, `false` if an error occurred or the operation
  88  * timed out..
  89  */
  90 bool _sir_condwait_timeout(sir_condition* cond, sir_mutex* mutex, const sir_wait* howlong);
  91 
  92 #endif /* !_SIR_CONDITION_H_INCLUDED */

/* [previous][next][first][last][top][bottom][index][help] */