Execution doesn't wait on semaphore (or cond var)

BlitzMax Forums/BlitzMax Programming/Execution doesn't wait on semaphore (or cond var)

jtfrench(Posted 2010) [#1]
I have this odd problem in that I've created a function intended for a child thread, and it was supposed to wait for a signal to be broadcast before executing, but it never did. The code would hit the WaitCondVar line, and keep going regardless of the signal.

I then thought, perhaps I should use semaphores instead, but the same thing occurs. I create the semaphore, then in the child thread i do WaitSemaphore, waiting for the main thread to PostSemaphore. Code execution marches right past it again. Here's my function:

Function t_handleRequests:Object(data:Object)
	toLog "Just getting ready for work...", 2
	Local myTransport:TCurlEasy = TCurlEasy.Create();
	toLog "Created Curl Transport for child thread"
	While(True)
		WaitSemaphore(TheSemaphore);
		toLog "Someone incremented semaphore. Decrementing..." 'this gets called repeatedly, even w/o the code ever reaching the place where PostSemaphore is
		saveLog();
		RUNTIME.mServer.mRequesterChild = myTransport;
		RUNTIME.sync();
	Wend
	
	toLog "Processing thread complete."
EndFunction


This has been plaguing me for weeks, and has essentially prevented me from fully incorporating multiple threads into my game. Any idea of what I'm missing here?

Thanks,

Jason