2 * thread.library - threading and synchronisation primitives
4 * Copyright © 2007 Robert Norris
6 * This program is free software; you can redistribute it and/or modify it
7 * under the same terms as AROS itself.
10 #include "thread_intern.h"
12 #include <exec/semaphores.h>
13 #include <proto/exec.h>
16 /*****************************************************************************
19 AROS_LH1(BOOL
, DestroyMutex
,
22 AROS_LHA(void *, mutex
, A0
),
25 struct ThreadBase
*, ThreadBase
, 11, Thread
)
31 mutex - the mutex to destroy.
34 TRUE if the mutex was destroyed, otherwise FALSE.
37 You cannot destroy a mutex that is currently locked or has tasks
46 CreateMutex(), LockMutex(), TryLockMutex(), UnlockMutex()
49 Mutexes are implemented as thin wrappers around Exec semaphores.
51 *****************************************************************************/
55 assert(mutex
!= NULL
);
57 /* we can only destroy the mutex if its not held and noone is waiting */
59 if (((struct SignalSemaphore
*) mutex
)->ss_QueueCount
>= 0) {
65 FreeMem(mutex
, sizeof(struct SignalSemaphore
));