ObjFW
Loading...
Searching...
No Matches
OFPlainCondition.h
1/*
2 * Copyright (c) 2008-2024 Jonathan Schleifer <js@nil.im>
3 *
4 * All rights reserved.
5 *
6 * This file is part of ObjFW. It may be distributed under the terms of the
7 * Q Public License 1.0, which can be found in the file LICENSE.QPL included in
8 * the packaging of this file.
9 *
10 * Alternatively, it may be distributed under the terms of the GNU General
11 * Public License, either version 2 or 3, which can be found in the file
12 * LICENSE.GPLv2 or LICENSE.GPLv3 respectively included in the packaging of this
13 * file.
14 */
15
16#include "objfw-defs.h"
17
18#include "platform.h"
19
20#if !defined(OF_HAVE_THREADS) || \
21 (!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS))
22# error No conditions available!
23#endif
24
25/* For OFTimeInterval */
26#import "OFObject.h"
27#import "OFPlainMutex.h"
28
29#if defined(OF_HAVE_PTHREADS)
30# include <pthread.h>
31typedef pthread_cond_t OFPlainCondition;
32#elif defined(OF_WINDOWS)
33# include <windows.h>
34typedef struct {
35 HANDLE event;
36 volatile int count;
37} OFPlainCondition;
38#elif defined(OF_AMIGAOS)
39# include <exec/tasks.h>
40typedef struct {
41 struct OFPlainConditionWaitingTask {
42 struct Task *task;
43 unsigned char sigBit;
44 struct OFPlainConditionWaitingTask *next;
45 } *waitingTasks;
46} OFPlainCondition;
47#endif
48
49#ifdef __cplusplus
50extern "C" {
51#endif
52extern int OFPlainConditionNew(OFPlainCondition *condition);
53extern int OFPlainConditionSignal(OFPlainCondition *condition);
54extern int OFPlainConditionBroadcast(OFPlainCondition *condition);
55extern int OFPlainConditionWait(OFPlainCondition *condition,
56 OFPlainMutex *mutex);
57extern int OFPlainConditionTimedWait(OFPlainCondition *condition,
58 OFPlainMutex *mutex, OFTimeInterval timeout);
59#if defined(OF_AMIGAOS) || defined(DOXYGEN)
60extern int OFPlainConditionWaitOrExecSignal(OFPlainCondition *condition,
61 OFPlainMutex *mutex, ULONG *signalMask);
62extern int OFPlainConditionTimedWaitOrExecSignal(OFPlainCondition *condition,
63 OFPlainMutex *mutex, OFTimeInterval timeout, ULONG *signalMask);
64#endif
65extern int OFPlainConditionFree(OFPlainCondition *condition);
66#ifdef __cplusplus
67}
68#endif
double OFTimeInterval
A time interval in seconds.
Definition OFObject.h:150