cfuture-2.0: test/OurTasks.hs
module OurTasks where
import Control.Concurrent.CFuture
import Control.Concurrent (threadDelay)
-- |
-- The task used as an example.
task :: IO Int
task = sum <$> mapM subtask [1..10]
where
subtask :: Int -> IO Int
subtask n = do
print n
threadDelay 1000000
return $ 2 * n
cFunction :: CFuturePtr -> IO ()
cFunction ptr = forkFutureC ptr task
foreign export ccall cFunction :: CFuturePtr -> IO ()