История изменений
Исправление qnikst, (текущая версия) :
ммм.. например так:
main = go <$> newTChanIO
where
go ch = do
_ <- replicateM n $ forkIO worker
addTask 1000 "fooo"
where
addTask delay t = async $ do
threadDelay delay
atomically $ writeTChan ch (delay,t)
worker = do
(delay, t) <- atomicallty (readTChan ch)
run t
addTask delay t
run = undefined
Исправление qnikst, :
ммм.. например так:
main = go <$> newTChanIO
where
go ch = do
replicateM_ n $ async worker
addTask 1000 "fooo"
where
addTask delay t = async $ do
threadDelay delay
atomically $ writeTChan ch (delay,t)
worker = do
(delay, t) <- atomicallty (readTChan ch)
run t
addTask delay t
run = undefined
Исправление qnikst, :
ммм.. например так:
main = go <$> newTChanIO
where
go ch = do
replicateM_ n $ async (work ch)
addTask 1000 "fooo"
where
addTask delay t = async $ do
threadDelay delay
atomically $ writeTChan ch (delay,t)
work ch = do
(delay, t) <- atomicallty (readTChan ch)
run t
addTask delay t
run = undefined
Исправление qnikst, :
ммм.. например так:
main = go <$> newTChanIO
where
go ch = do
replicateM_ n $ async (work ch)
addTask 1000 "fooo"
where
addTask delay t = async $ do
threadDelay delay
atomically $ writeTChan ch (delay,t)
work ch = do
(delay, t) <- tomicallty (readTChan ch)
run t
addTask delay t
run = undefined
Исходная версия qnikst, :
ммм.. например так:
main = go <$> newTChanIO
where
go ch = do
workersIds <- replicateM_ n $ async (work ch)
addTask 1000 "fooo"
where
addTask delay t = async $ do
threadDelay delay
atomically $ writeTChan ch (delay,t)
work ch = do
(delay, t) <- tomicallty (readTChan ch)
run t
addTask delay t
run = undefined