threads and timing

BlitzMax Forums/BlitzMax Programming/threads and timing

AdamStrange(Posted 2013) [#1]
I've got two questions:

1. is there a better way to do timed events other that using the event timer. I get periodic dropouts (missed events).

2. Related to above. I want to put a midi system into a separate thread so it just passes on events when needed. what is the best way to do this without dropping timing?


Brucey(Posted 2013) [#2]
If you have a lot of time-sensitive action going on, you may be better splitting things into multiple threads, as you've discovered.
I have an app with a thread processing serial data (in/out) at about 84 hz, a gui (main) thread running at 60hz, and another manager thread processing the serial data as it arrives and making data available for display and re-processing.

I imagine there are many different ways to go about it. There are probably design patterns for just this thing too.


AdamStrange(Posted 2013) [#3]
mm ok, I've never worked with threads before. What would you suggest is a good place to start?


AdamStrange(Posted 2013) [#4]
ok, update on this.

I've checked out the thread demos and come up with an alternative timing method using a worker thread that sends out the exact timing I need via a postevent.

Converted the main core from waitevent to poll event, making sure that time is given back to the system.

Good learning curve and works better that the straight set timer event. Even in debug the timing is not far off :)

Now I need to deal with the midi side of things...