C++ semaphore count seems not work
I create a semaphore and use ReleaseSemaphore to check the previous count. but everytime I got 0.
any clue ?
1 2 3 4 5 6 7 8 9 10 11 12
|
HANDLE hSemaphore = CreateSemaphore(NULL, 0,10, "My Semaphore Name");
dwWaitResult = WaitForSingleObject(
hSemaphore, // handle to semaphore
tmout);
LONG prev_counter;
bool ret;
ret=ReleaseSemaphore(hSemaphore, incnt, &prev_counter);
if(ret) std::cout<<"prev_counter="<<prev_counter<<std::endl;
ret=ReleaseSemaphore(hSemaphore, incnt, &prev_counter);
if(ret) std::cout<<"prev_counter="<<prev_counter<<std::endl;
|
Topic archived. No new replies allowed.