I have a lib that only expose a blocking theRead function on a streaming data. Now I need to theRead data and show in GTK3 GUI. So I used a transaction channel to pass data from a thread running theRead to GUI thread then read the var via g_idle_add. Apparently this is wrong. The application caused CPU busy. What is the proper way?
Psudo code:
idleAdd PRIORITY_DEFAULT_IDLE $ do
readTChan chan >>= \case
Nothing -> return SOURCE_CONTINUE
Just data -> show_data_in_textview data
forkIO $ loop $ do
theRead >>= writeTChan chan