esl_threadmutex.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Cross Platform Thread/Mutex abstraction
  3. * Copyright(C) 2007 Michael Jerris
  4. *
  5. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  6. * copies of the Software, and permit persons to whom the Software is
  7. * furnished to do so.
  8. *
  9. * This work is provided under this license on an "as is" basis, without warranty of any kind,
  10. * either expressed or implied, including, without limitation, warranties that the covered code
  11. * is free of defects, merchantable, fit for a particular purpose or non-infringing. The entire
  12. * risk as to the quality and performance of the covered code is with you. Should any covered
  13. * code prove defective in any respect, you (not the initial developer or any other contributor)
  14. * assume the cost of any necessary servicing, repair or correction. This disclaimer of warranty
  15. * constitutes an essential part of this license. No use of any covered code is authorized hereunder
  16. * except under this disclaimer.
  17. *
  18. */
  19. #ifndef _ESL_THREADMUTEX_H
  20. #define _ESL_THREADMUTEX_H
  21. #include "esl.h"
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif /* defined(__cplusplus) */
  25. typedef struct esl_mutex esl_mutex_t;
  26. typedef struct esl_thread esl_thread_t;
  27. typedef void *(*esl_thread_function_t) (esl_thread_t *, void *);
  28. ESL_DECLARE(esl_status_t) esl_thread_create_detached(esl_thread_function_t func, void *data);
  29. esl_status_t esl_thread_create_detached_ex(esl_thread_function_t func, void *data, size_t stack_size);
  30. void esl_thread_override_default_stacksize(size_t size);
  31. ESL_DECLARE(esl_status_t) esl_mutex_create(esl_mutex_t **mutex);
  32. ESL_DECLARE(esl_status_t) esl_mutex_destroy(esl_mutex_t **mutex);
  33. ESL_DECLARE(esl_status_t) esl_mutex_lock(esl_mutex_t *mutex);
  34. ESL_DECLARE(esl_status_t) esl_mutex_trylock(esl_mutex_t *mutex);
  35. ESL_DECLARE(esl_status_t) esl_mutex_unlock(esl_mutex_t *mutex);
  36. #ifdef __cplusplus
  37. }
  38. #endif /* defined(__cplusplus) */
  39. #endif /* defined(_ESL_THREADMUTEX_H) */
  40. /* For Emacs:
  41. * Local Variables:
  42. * mode:c
  43. * indent-tabs-mode:t
  44. * tab-width:4
  45. * c-basic-offset:4
  46. * End:
  47. * For VIM:
  48. * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet:
  49. */