diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/eina/src/include/eina_inline_lock_win32.x | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/libraries/eina/src/include/eina_inline_lock_win32.x b/libraries/eina/src/include/eina_inline_lock_win32.x index 072095c..e8363d5 100644 --- a/libraries/eina/src/include/eina_inline_lock_win32.x +++ b/libraries/eina/src/include/eina_inline_lock_win32.x | |||
@@ -58,6 +58,8 @@ struct _Eina_Win32_RWLock | |||
58 | 58 | ||
59 | typedef DWORD Eina_TLS; | 59 | typedef DWORD Eina_TLS; |
60 | 60 | ||
61 | typedef HANDLE Eina_Semaphore; | ||
62 | |||
61 | EAPI extern Eina_Bool _eina_threads_activated; | 63 | EAPI extern Eina_Bool _eina_threads_activated; |
62 | 64 | ||
63 | static inline Eina_Bool | 65 | static inline Eina_Bool |
@@ -463,4 +465,48 @@ eina_tls_set(Eina_TLS key, const void *data) | |||
463 | return EINA_TRUE; | 465 | return EINA_TRUE; |
464 | } | 466 | } |
465 | 467 | ||
468 | static inline Eina_Bool | ||
469 | eina_semaphore_new(Eina_Semaphore *sem, int count_init) | ||
470 | { | ||
471 | if (!sem || (count_init <= 0)) | ||
472 | return EINA_FALSE; | ||
473 | |||
474 | *sem = CreateSemaphore(NULL, count_init, 32767, NULL); | ||
475 | if (!*sem) | ||
476 | return EINA_FALSE; | ||
477 | } | ||
478 | |||
479 | static inline Eina_Bool | ||
480 | eina_semaphore_free(Eina_Semaphore *sem) | ||
481 | { | ||
482 | if (!sem) | ||
483 | return EINA_FALSE; | ||
484 | |||
485 | CloseHandle(*sem); | ||
486 | } | ||
487 | |||
488 | static inline Eina_Bool | ||
489 | eina_semaphore_lock(Eina_Semaphore *sem) | ||
490 | { | ||
491 | DWORD res; | ||
492 | |||
493 | if (!sem) | ||
494 | return EINA_FALSE; | ||
495 | |||
496 | res = WaitForSingleObject(*sem, 0L); | ||
497 | if (res == WAIT_OBJECT_0) | ||
498 | return EINA_TRUE; | ||
499 | |||
500 | return EINA_FALSE; | ||
501 | } | ||
502 | |||
503 | static inline Eina_Bool | ||
504 | eina_semaphore_release(Eina_Semaphore *sem, int count_release) | ||
505 | { | ||
506 | if (!sem) | ||
507 | return EINA_FALSE; | ||
508 | |||
509 | return ReleaseSemaphore(*sem, count_release, NULL) ? EINA_TRUE : EINA_FALSE; | ||
510 | } | ||
511 | |||
466 | #endif | 512 | #endif |