bugfact: > Consider the following code > > stamp v x = do > t <- getCurrentTime > putMVar v (x,t) > > Is it possible - with GHC - that a thread switch happens after the t <- > getCurrentTime and the putMVar v (x,t)?
Yes. if 't' is heap allocated, there could be a context switch. > If so, how would it be possible to make sure that the operation of reading the > current time and writing the pair to the MVar is an "atomic" operation, in the > sense that no thread switch can happen between the two? Would this require > STM? > Using 'atomically' and TVars in STM, perhaps? Else, use withMVar? Or a modifyMVar in IO? -- Don _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe