123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "pthread.h"
- #include "implement.h"
- static void
- pte_threadDestroyCommon (pthread_t thread, unsigned char shouldThreadExit)
- {
- pte_thread_t * tp = (pte_thread_t *) thread.p;
- pte_thread_t threadCopy;
- if (tp != NULL)
- {
-
- memcpy (&threadCopy, tp, sizeof (threadCopy));
-
- pte_threadReusePush (thread);
- (void) pthread_mutex_destroy(&threadCopy.cancelLock);
- (void) pthread_mutex_destroy(&threadCopy.threadLock);
- if (threadCopy.threadId != 0)
- {
- if (shouldThreadExit)
- {
- pte_osThreadExitAndDelete(threadCopy.threadId);
- }
- else
- {
- pte_osThreadDelete(threadCopy.threadId);
- }
- }
- }
- }
- void pte_threadDestroy (pthread_t thread)
- {
- pte_threadDestroyCommon(thread,0);
- }
- void pte_threadExitAndDestroy (pthread_t thread)
- {
- pte_threadDestroyCommon(thread,1);
- }
|