ObjFW  Diff

Differences From Artifact [c4030c17c8]:

To Artifact [2b26bbac16]:


25
26
27
28
29
30
31


32
33
34
35
36
37
38
    (!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS))
# error No conditions available!
#endif

/* For OFTimeInterval */
#import "OFObject.h"
#import "OFPlainMutex.h"



#if defined(OF_HAVE_PTHREADS)
# include <pthread.h>
typedef pthread_cond_t OFPlainCondition;
#elif defined(OF_WINDOWS)
# include <windows.h>
typedef struct {







>
>







25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
    (!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS))
# error No conditions available!
#endif

/* For OFTimeInterval */
#import "OFObject.h"
#import "OFPlainMutex.h"

/** @file */

#if defined(OF_HAVE_PTHREADS)
# include <pthread.h>
typedef pthread_cond_t OFPlainCondition;
#elif defined(OF_WINDOWS)
# include <windows.h>
typedef struct {
49
50
51
52
53
54
55









56







57








58








59
60










61
62

63









64
65











66
67
68







69
70
71
72
	} *waitingTasks;
} OFPlainCondition;
#endif

#ifdef __cplusplus
extern "C" {
#endif









extern int OFPlainConditionNew(OFPlainCondition *condition);







extern int OFPlainConditionSignal(OFPlainCondition *condition);








extern int OFPlainConditionBroadcast(OFPlainCondition *condition);








extern int OFPlainConditionWait(OFPlainCondition *condition,
    OFPlainMutex *mutex);










extern int OFPlainConditionTimedWait(OFPlainCondition *condition,
    OFPlainMutex *mutex, OFTimeInterval timeout);

#if defined(OF_AMIGAOS) || defined(DOXYGEN)









extern int OFPlainConditionWaitOrExecSignal(OFPlainCondition *condition,
    OFPlainMutex *mutex, ULONG *signalMask);











extern int OFPlainConditionTimedWaitOrExecSignal(OFPlainCondition *condition,
    OFPlainMutex *mutex, OFTimeInterval timeout, ULONG *signalMask);
#endif







extern int OFPlainConditionFree(OFPlainCondition *condition);
#ifdef __cplusplus
}
#endif







>
>
>
>
>
>
>
>
>

>
>
>
>
>
>
>

>
>
>
>
>
>
>
>

>
>
>
>
>
>
>
>


>
>
>
>
>
>
>
>
>
>


>

>
>
>
>
>
>
>
>
>


>
>
>
>
>
>
>
>
>
>
>



>
>
>
>
>
>
>




51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
	} *waitingTasks;
} OFPlainCondition;
#endif

#ifdef __cplusplus
extern "C" {
#endif
/**
 * @brief Creates a new plain condition.
 *
 * A plain condition is similar to an @ref OFCondition, but does not use
 * exceptions and can be used from pure C code.
 *
 * @param condition A pointer to the condition to create
 * @return 0 on success, or an error number from `<errno.h>` on error
 */
extern int OFPlainConditionNew(OFPlainCondition *condition);

/**
 * @brief Signals the specified condition.
 *
 * @param condition A pointer to the condition to signal
 * @return 0 on success, or an error number from `<errno.h>` on error
 */
extern int OFPlainConditionSignal(OFPlainCondition *condition);

/**
 * @brief Broadcasts the specified condition, meaning it will be signaled to
 *	  everyone waiting.
 *
 * @param condition A pointer to the condition to broadcast
 * @return 0 on success, or an error number from `<errno.h>` on error
 */
extern int OFPlainConditionBroadcast(OFPlainCondition *condition);

/**
 * @brief Waits on the specified condition with the specified mutex.
 *
 * @param condition A pointer to the condition to wait on
 * @param mutex The mutex to wait with
 * @return 0 on success, or an error number from `<errno.h>` on error
 */
extern int OFPlainConditionWait(OFPlainCondition *condition,
    OFPlainMutex *mutex);

/**
 * @brief Waits on the specified condition with the specified mutex with a
 *	  timeout.
 *
 * @param condition A pointer to the condition to wait on
 * @param mutex The mutex to wait with
 * @param timeout The timeout after which to give up
 * @return 0 on success, or an error number from `<errno.h>` on error
 */
extern int OFPlainConditionTimedWait(OFPlainCondition *condition,
    OFPlainMutex *mutex, OFTimeInterval timeout);

#if defined(OF_AMIGAOS) || defined(DOXYGEN)
/**
 * @brief Waits on the specified condition with the specified mutex or the
 *	  specified Exec signal.
 *
 * @param condition A pointer to the condition to wait on
 * @param mutex The mutex to wait with
 * @param signalMask The Exec signal mask to wait for
 * @return 0 on success, or an error number from `<errno.h>` on error
 */
extern int OFPlainConditionWaitOrExecSignal(OFPlainCondition *condition,
    OFPlainMutex *mutex, ULONG *signalMask);

/**
 * @brief Waits on the specified condition with the specified mutex or the
 *	  specified Exec signal, up until the timeout is reached.
 *
 * @param condition A pointer to the condition to wait on
 * @param mutex The mutex to wait with
 * @param signalMask The Exec signal mask to wait for
 * @param timeout The timeout after which to give up
 * @return 0 on success, or an error number from `<errno.h>` on error
 */
extern int OFPlainConditionTimedWaitOrExecSignal(OFPlainCondition *condition,
    OFPlainMutex *mutex, OFTimeInterval timeout, ULONG *signalMask);
#endif

/**
 * @brief Destroys the specified plain condition.
 *
 * @param condition A pointer to the condition to destroy
 * @return 0 on success, or an error number from `<errno.h>` on error
 */
extern int OFPlainConditionFree(OFPlainCondition *condition);
#ifdef __cplusplus
}
#endif