os/graphics/graphicscomposition/openwfcompositionengine/adaptation/src/Platform/OS/symbian/owfthread.c
First public contribution.
1 /* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and/or associated documentation files (the
5 * "Materials"), to deal in the Materials without restriction, including
6 * without limitation the rights to use, copy, modify, merge, publish,
7 * distribute, sublicense, and/or sell copies of the Materials, and to
8 * permit persons to whom the Materials are furnished to do so, subject to
9 * the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Materials.
14 * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
35 #define _XOPEN_SOURCE 1 /* nanosleep */
44 #include "owfthread.h"
45 #include "owfmemory.h"
49 OWF_Thread_Destroy(OWF_THREAD thread)
53 OWF_Thread_Join(thread, NULL);
58 OWF_API_CALL OWF_THREAD
59 OWF_Thread_Create(void* (*threadfunc)(void*), void* data)
63 handle = (pthread_t*)xalloc(sizeof(pthread_t), 1);
69 if (pthread_create(handle, NULL, threadfunc, data))
75 return (OWF_THREAD) handle;
79 OWF_Thread_Join(OWF_THREAD thread, void** retval)
87 ret = (int) pthread_join(*(pthread_t*) thread, retval);
92 OWF_Thread_Cancel(OWF_THREAD thread)
100 OWF_Thread_Exit(void* retval)
102 pthread_exit(retval);
106 OWF_Thread_MicroSleep(OWFuint32 usecs)
108 #if _POSIX_C_SOURCE >= 199309L
110 ts.tv_sec = usecs / 1000000;
111 ts.tv_nsec = (usecs % 1000000) * 1000;
112 nanosleep(&ts, NULL);
119 OWF_Thread_Sleep(OWFuint32 secs)