Event handling with channels
Posted: Fri Mar 18, 2016 3:56 pm
What is the best practice to write event based system using channels?
I now have UIThread that handles all physical buttons and handling screen updates.
I listen button and if that is pressed it sends 1 to channel that is in listened in another thread that calculates audio.
Problem is that if i listen same channel in UIThread, with case (like case: 2 { do something}) it stalls until i send something back on that channel. If i send random number back, UIThread keeps running on while loop, but not reacting to that anymore.
So to clarify:
I have setup my channels like:
uiHandler(uiTrigger);
trigger(uiTrigger,c_synth_audio);
When I have send data to channel from UIHandler it should check when it gets value 2 back from that channel and then print something to screen. Once i have send value to channel, trigger starts playing audio as it should, but uiHandler is stuck until it get data back from channel.
I now have UIThread that handles all physical buttons and handling screen updates.
I listen button and if that is pressed it sends 1 to channel that is in listened in another thread that calculates audio.
Problem is that if i listen same channel in UIThread, with case (like case: 2 { do something}) it stalls until i send something back on that channel. If i send random number back, UIThread keeps running on while loop, but not reacting to that anymore.
So to clarify:
I have setup my channels like:
uiHandler(uiTrigger);
trigger(uiTrigger,c_synth_audio);
When I have send data to channel from UIHandler it should check when it gets value 2 back from that channel and then print something to screen. Once i have send value to channel, trigger starts playing audio as it should, but uiHandler is stuck until it get data back from channel.