1 // Copyright 2009-2021 Intel Corporation 2 // SPDX-License-Identifier: Apache-2.0 3 4 #pragma once 5 6 #include "platform.h" 7 #include "mutex.h" 8 #include "alloc.h" 9 #include "vector.h" 10 #include <vector> 11 12 namespace embree 13 { 14 /*! type for thread */ 15 typedef struct opaque_thread_t* thread_t; 16 17 /*! signature of thread start function */ 18 typedef void (*thread_func)(void*); 19 20 /*! creates a hardware thread running on specific logical thread */ 21 thread_t createThread(thread_func f, void* arg, size_t stack_size = 0, ssize_t threadID = -1); 22 23 /*! set affinity of the calling thread */ 24 void setAffinity(ssize_t affinity); 25 26 /*! the thread calling this function gets yielded */ 27 void yield(); 28 29 /*! waits until the given thread has terminated */ 30 void join(thread_t tid); 31 32 /*! destroy handle of a thread */ 33 void destroyThread(thread_t tid); 34 35 /*! type for handle to thread local storage */ 36 typedef struct opaque_tls_t* tls_t; 37 38 /*! creates thread local storage */ 39 tls_t createTls(); 40 41 /*! set the thread local storage pointer */ 42 void setTls(tls_t tls, void* const ptr); 43 44 /*! return the thread local storage pointer */ 45 void* getTls(tls_t tls); 46 47 /*! destroys thread local storage identifier */ 48 void destroyTls(tls_t tls); 49 } 50