thread.h 1.1 KB

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