Threading and polling
BlitzMax Forums/BlitzMax Programming/Threading and polling
| ||
Just having a play around with some threading code - its not supposed to be anything spectacular. In the example below, the oval (which should be drawn at the mouse coords) only moves once per second due to the Delay function being used in the main thread. Is this expected behaviour? Limitation of system polling? I tried calling PollSystem from the thread but it made no difference. Graphics 800, 600 Local t:TThread = CreateThread(myThread, Null) While Not KeyDown(KEY_ESCAPE) Delay 1000 Wend End Function myThread:Object(data:Object) Repeat Cls DrawText MilliSecs(), 20, 20 DrawOval MouseX(), MouseY(), 5, 5 Flip Forever End Function |
| ||
I think possibly that this all revolves around the Delay function, which in my eyes is telling the operating system to put your *process* on hold for 1 second. Since your process sort of `contains` your threads, I would assume this to mean that your threads go on hold too? I'm not sure, but this is my best guess. If PollSystem is doing the same thing, then maybe it's having the same effect - ie the o/s has to take over and it temporarily places the process on hold and freezes all cpu-time for the whole application? I'm not sure if polling/delay could be made to be threaded, given that it's basically saying `I will give control over to the o/s and wait until it tells me to continue`? Would be good to know what is happening either under the hood or by the o/s. |