pythread.pxd 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. cdef extern from "pythread.h":
  2. ctypedef void *PyThread_type_lock
  3. ctypedef void *PyThread_type_sema
  4. void PyThread_init_thread()
  5. long PyThread_start_new_thread(void (*)(void *), void *) # FIXME: legacy
  6. #unsigned long PyThread_start_new_thread(void (*)(void *), void *) # returned 'long' before Py3.7
  7. void PyThread_exit_thread()
  8. long PyThread_get_thread_ident() # FIXME: legacy
  9. #unsigned long PyThread_get_thread_ident() # returned 'long' before Py3.7
  10. PyThread_type_lock PyThread_allocate_lock()
  11. void PyThread_free_lock(PyThread_type_lock)
  12. int PyThread_acquire_lock(PyThread_type_lock, int mode) nogil
  13. void PyThread_release_lock(PyThread_type_lock) nogil
  14. enum:
  15. # 'mode' in PyThread_acquire_lock()
  16. WAIT_LOCK # 1
  17. NOWAIT_LOCK # 0
  18. ctypedef enum PyLockStatus:
  19. # return values of PyThread_acquire_lock() in CPython 3.2+
  20. PY_LOCK_FAILURE = 0
  21. PY_LOCK_ACQUIRED = 1
  22. PY_LOCK_INTR
  23. size_t PyThread_get_stacksize()
  24. int PyThread_set_stacksize(size_t)
  25. # Thread Local Storage (TLS) API deprecated in CPython 3.7+
  26. int PyThread_create_key()
  27. void PyThread_delete_key(int)
  28. int PyThread_set_key_value(int, void *)
  29. void * PyThread_get_key_value(int)
  30. void PyThread_delete_key_value(int key)
  31. # Cleanup after a fork
  32. void PyThread_ReInitTLS()
  33. # Thread Specific Storage (TSS) API in CPython 3.7+ (also backported)
  34. #ctypedef struct Py_tss_t: pass # Cython built-in type
  35. Py_tss_t Py_tss_NEEDS_INIT # Not normally useful: Cython auto-initialises declared "Py_tss_t" variables.
  36. Py_tss_t * PyThread_tss_alloc()
  37. void PyThread_tss_free(Py_tss_t *key)
  38. int PyThread_tss_is_created(Py_tss_t *key)
  39. int PyThread_tss_create(Py_tss_t *key)
  40. void PyThread_tss_delete(Py_tss_t *key)
  41. int PyThread_tss_set(Py_tss_t *key, void *value)
  42. void * PyThread_tss_get(Py_tss_t *key)