aboutsummaryrefslogtreecommitdiff
path: root/src/threading/thread.cpp
Commit message (Expand)AuthorAge
* DragonFly BSD is somewhat identical to FreeBSD (#8159)Leonid Bobrov2019-02-03
* Thread: fix a crash on Windows due to data race condition on Thread::m_start_...Loïc Blot2017-10-10
* Fix msvc annoyances (#5963)adrido2017-06-27
* C++11 cleanup on constructors (#6000)Vincent Glize2017-06-19
* Remove threads.h and replace its definitions with their C++11 equivalents (#5...ShadowNinja2017-06-11
* C++11 patchset 5: use std::threads and remove old compat layer (#5928)Loïc Blot2017-06-08
* Fix AIX threading buildShadowNinja2017-01-28
* Fix synchronization issue at thread startShadowNinja2017-01-28
* Fix C++11 Windows build of threading codesfan52016-10-06
* Fix & make linux conditionals uniform (#4278)Rogier-52016-07-04
* Fix POSIX C++11 buildShadowNinja2016-04-30
* Fix race on thread creationShadowNinja2016-04-28
* Fix misc. MinGW and Valgrind warningskwolekr2015-11-08
* Fix C++11 compatibilitykwolekr2015-10-31
* Fix some threading things and add additional thread unittestskwolekr2015-10-24
* Fix == to =Rui2015-10-17
* Refactor Thread class to improve readability and portabilitykwolekr2015-10-16
* Refactor loggingShadowNinja2015-10-14
* Fix building on OSX, broken since "Clean up threading"Pavel Puchkin2015-09-06
* Clean up threadingShadowNinja2015-08-23
>( 0, initval, MAX_SEMAPHORE_COUNT, 0); } void JSemaphore::Post() { ReleaseSemaphore( m_hSemaphore, 1, 0); } void JSemaphore::Wait() { WaitForSingleObject( m_hSemaphore, INFINITE); } bool JSemaphore::Wait(unsigned int time_ms) { unsigned int retval = WaitForSingleObject( m_hSemaphore, time_ms); if (retval == WAIT_OBJECT_0) { return true; } else { assert(retval == WAIT_TIMEOUT); return false; } } typedef LONG (NTAPI *_NtQuerySemaphore)( HANDLE SemaphoreHandle, DWORD SemaphoreInformationClass, PVOID SemaphoreInformation, ULONG SemaphoreInformationLength, PULONG ReturnLength OPTIONAL ); typedef struct _SEMAPHORE_BASIC_INFORMATION { ULONG CurrentCount; ULONG MaximumCount; } SEMAPHORE_BASIC_INFORMATION; /* Note: this will only work as long as jthread is directly linked to application */ /* it's gonna fail if someone tries to build jthread as dll */ static _NtQuerySemaphore NtQuerySemaphore = (_NtQuerySemaphore) GetProcAddress (GetModuleHandle ("ntdll.dll"), "NtQuerySemaphore"); int JSemaphore::GetValue() { SEMAPHORE_BASIC_INFORMATION BasicInfo; LONG retval; assert(NtQuerySemaphore); retval = NtQuerySemaphore (m_hSemaphore, 0, &BasicInfo, sizeof (SEMAPHORE_BASIC_INFORMATION), NULL); if (retval == ERROR_SUCCESS) { return BasicInfo.CurrentCount; } else { assert("unable to read semaphore count" == 0); } }