HpThread.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*****************************************************************************
  2. * HpThread.h
  3. *****************************************************************************
  4. *
  5. * Project: Halcon/libhalcon
  6. * Description: implements a programming interface to Posix or DCE
  7. * thread-packages for different operating systems.
  8. *
  9. * (c) 1996-2022 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. #include "HBase.h"
  19. #include "HDeclSpec.h"
  20. /*===========================================================================*/
  21. /* Prototypes of Functions */
  22. /*===========================================================================*/
  23. /* --- Thread Synchronization --------------- */
  24. /* type of dynamically set synchronisation functions */
  25. typedef Herror (*H_THREAD_MUTEX_FCT)(H_pthread_mutex_t* hmutex);
  26. typedef bool (*H_THREAD_MUTEX_BFCT)(H_pthread_mutex_t* hmutex);
  27. /* general mutex */
  28. extern HLibExport Herror HpThreadMutexInit(H_pthread_mutex_t* hmutex);
  29. /* dynamically set synchronisation functions */
  30. extern HLibExport H_THREAD_MUTEX_FCT HpThreadMutexLock;
  31. extern HLibExport H_THREAD_MUTEX_FCT HpThreadMutexUnlock;
  32. extern HLibExport H_THREAD_MUTEX_BFCT HpThreadMutexTrylock;
  33. extern HLibExport Herror HpThreadMutexDestroy(H_pthread_mutex_t* hmutex);
  34. /* --- Threads -------------------------------*/
  35. /* HpThreadHandleAlloc - allocate pthread handle (identifier of pthread) */
  36. extern HLibExport Herror HpThreadHandleAlloc(H_pthread_t* handle);
  37. /* HpThreadHandleFree - give pthread handle (identifier of pthread) free */
  38. extern HLibExport Herror HpThreadHandleFree(H_pthread_t handle);
  39. /* HpThreadCreate - create pthread object and start pthread asynchronously */
  40. extern HLibExport Herror HpThreadCreate(H_pthread_t handle, void** parameters,
  41. Herror (*function)(void**));
  42. /* HpThreadClear - frees resources allocated by HpThreadCreate */
  43. extern HLibExport Herror HpThreadClear(H_pthread_t handle);
  44. /* HpThreadSelf - get calling thread's identifier (UNIX) or handle (Windows) */
  45. extern HLibExport Herror HpThreadSelf(H_pthread_t* my_handle);
  46. /* HpThreadSelfId - get calling thread's identifier */
  47. extern HLibExport Herror HpThreadSelfId(void* thread_id);
  48. /* HpThreadEqualToSelf - compare a thread identifier to current thread */
  49. extern HLibExport Herror HpThreadEqualToSelf(H_pthread_t t_handle,
  50. int* result_val);
  51. /* HpThreadJoin - wait for termination of specified pthread */
  52. extern HLibExport Herror HpThreadJoin(H_pthread_t handle);
  53. /* HpThreadDetach - detach pthread, mark the pthread object for deletion */
  54. extern HLibExport Herror HpThreadDetach(H_pthread_t handle);
  55. #if defined(__cplusplus)
  56. }
  57. #endif
  58. #endif