From: Tim D. <tw...@do...> - 2008-04-08 14:12:51
|
Hi, If I add code to the progressthreadedrts.hs demo to log the thread ids, it's not what I expect. The posted action seems to run in a thread different each time. In the output below, each "posted" output gets a different thread id. Is this expected? Tim import Graphics.UI.Gtk import Control.Concurrent main :: IO () main = do -- It is marked unsafe becuase it is your obligation to ensure you -- only call Gtk+ from one OS thread, or 'bad things' will happen. unsafeInitGUIForThreadedRTS logT "start" dia <- dialogNew dialogAddButton dia stockClose ResponseClose contain <- dialogGetUpper dia pb <- progressBarNew boxPackStartDefaults contain pb widgetShowAll dia forkIO (doTask pb) dialogRun dia return () logT :: String -> IO () logT msg = do tid <- myThreadId putStrLn (show tid ++ ": " ++ msg) doTask :: ProgressBar -> IO () doTask pb = do logT "task" postGUIAsync $ do logT "posted" progressBarPulse pb threadDelay 100000 doTask pb ---------------------------------- $ ./progressThreadedRTS ThreadId 3: start ThreadId 4: task ThreadId 5: posted ThreadId 4: task ThreadId 7: posted ThreadId 4: task ThreadId 9: posted ThreadId 4: task ThreadId 11: posted ThreadId 4: task ThreadId 13: posted ThreadId 4: task ThreadId 15: posted ThreadId 4: task ThreadId 17: posted ThreadId 4: task ThreadId 19: posted ThreadId 4: task ThreadId 21: posted |