HpThread.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*****************************************************************************
  2. * HpThread.h
  3. *****************************************************************************
  4. *
  5. * Projekt: Halcon/libhalcon
  6. * Description: implements a programming interface to Posix or DCE
  7. * thread-packages for different operating systems.
  8. *
  9. * (c) 1996-2020 by MVTec Software GmbH
  10. * www.mvtec.com
  11. *
  12. *****************************************************************************/
  13. #ifndef HPTHREAD_H
  14. #define HPTHREAD_H
  15. #if defined(__cplusplus)
  16. extern "C" {
  17. #endif
  18. /*===========================================================================*/
  19. /* Prototypes of Functions */
  20. /*===========================================================================*/
  21. /* --- Thread Synchronization --------------- */
  22. /* type of dynamically set synchronisation functions */
  23. typedef Herror (*H_THREAD_MUTEX_FCT)(H_pthread_mutex_t* hmutex);
  24. typedef HBOOL (*H_THREAD_MUTEX_BFCT)(H_pthread_mutex_t* hmutex);
  25. /* general mutex */
  26. extern HLibExport Herror HpThreadMutexInit(H_pthread_mutex_t* hmutex);
  27. /* dynamically set synchronisation functions */
  28. extern HLibExport H_THREAD_MUTEX_FCT HpThreadMutexLock;
  29. extern HLibExport H_THREAD_MUTEX_FCT HpThreadMutexUnlock;
  30. extern HLibExport H_THREAD_MUTEX_BFCT HpThreadMutexTrylock;
  31. extern HLibExport Herror HpThreadMutexDestroy(H_pthread_mutex_t* hmutex);
  32. /* --- Threads -------------------------------*/
  33. /* HpThreadHandleAlloc - allocate pthread handle (identifier of pthread) */
  34. extern HLibExport Herror HpThreadHandleAlloc(H_pthread_t* handle);
  35. /* HpThreadHandleFree - give pthread handle (identifier of pthread) free */
  36. extern HLibExport Herror HpThreadHandleFree(H_pthread_t handle);
  37. /* HpThreadCreate - create pthread object and start pthread asynchronously */
  38. extern HLibExport Herror HpThreadCreate(H_pthread_t handle, void** parameters,
  39. Herror (*function)(void**));
  40. /* HpThreadClear - frees resources allocated by HpThreadCreate */
  41. extern HLibExport Herror HpThreadClear(H_pthread_t handle);
  42. /* HpThreadSelf - get calling thread's identifier (UNIX) or handle (Windows) */
  43. extern HLibExport Herror HpThreadSelf(H_pthread_t* my_handle);
  44. /* HpThreadSelfId - get calling thread's identifier */
  45. extern HLibExport Herror HpThreadSelfId(void* thread_id);
  46. /* HpThreadEqualToSelf - compare a thread identifier to current thread */
  47. extern HLibExport Herror HpThreadEqualToSelf(H_pthread_t t_handle,
  48. HINT* result_val);
  49. /* HpThreadJoin - wait for termination of specified pthread */
  50. extern HLibExport Herror HpThreadJoin(H_pthread_t handle);
  51. /* HpThreadDetach - detach pthread, mark the pthread object for deletion */
  52. extern HLibExport Herror HpThreadDetach(H_pthread_t handle);
  53. #if defined(__cplusplus)
  54. }
  55. #endif
  56. #endif