183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
|
- init
{
self = [super init];
#ifndef _WIN32
if (pthread_mutex_init(&mutex, NULL)) {
#else
if ((mutex = CreateMutex(NULL, FALSE, NULL)) == NULL) {
#endif
Class c = isa;
[self dealloc];
@throw [OFInitializationFailedException newWithClass: c];
}
return self;
}
- lock
{
/* FIXME: Add error-handling */
#ifndef _WIN32
pthread_mutex_lock(&mutex);
#else
WaitForSingleObject(mutex, INFINITE);
#endif
return self;
}
- unlock
{
/* FIXME: Add error-handling */
#ifndef _WIN32
pthread_mutex_unlock(&mutex);
#else
ReleaseMutex(mutex);
#endif
return self;
}
@end
|
<
<
<
>
>
>
<
>
|
<
>
|
>
>
>
>
>
>
>
>
>
>
>
>
|
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
- init
{
self = [super init];
#ifndef _WIN32
if (pthread_mutex_init(&mutex, NULL)) {
Class c = isa;
[self dealloc];
@throw [OFInitializationFailedException newWithClass: c];
}
#else
InitializeCriticalSection(&mutex);
#endif
return self;
}
- lock
{
#ifndef _WIN32
/* FIXME: Add error-handling */
pthread_mutex_lock(&mutex);
#else
EnterCriticalSection(&mutex);
#endif
return self;
}
- unlock
{
#ifndef _WIN32
/* FIXME: Add error-handling */
pthread_mutex_unlock(&mutex);
#else
LeaveCriticalSection(&mutex);
#endif
return self;
}
- (void)dealloc
{
#ifndef _WIN32
/* FIXME: Add error-handling */
pthread_mutex_destroy(&mutex);
#else
DeleteCriticalSection(&mutex);
#endif
[super dealloc];
}
@end
|