mirror of
https://github.com/zhigang1992/graphql-engine.git
synced 2026-06-15 01:59:08 +08:00
We upload a set of accumulating timers and counters to track service time for different types of operations, across several dimensions (e.g. did we hit the plan cache, was a remote involved, etc.) Also... Standardize on DiffTime as a standard duration type, and try to use it consistently. See discussion here: https://github.com/hasura/graphql-engine/pull/3584#pullrequestreview-340679369 It should be possible to overwrite that module so the new threadDelay sticks per the pattern in #3705 blocked on #3558 Rename the Control.Concurrent.Extended.threadDelay to `sleep` since a naive use with a literal argument would be very bad! We catch a bug in 'computeTimeDiff'. Add convenient 'Read' instances to the time unit utility types. Make 'Second' a newtype to support this.
25 lines
756 B
Haskell
25 lines
756 B
Haskell
module Control.Concurrent.Extended
|
|
( module Control.Concurrent
|
|
, sleep
|
|
-- * Deprecated
|
|
, threadDelay
|
|
) where
|
|
|
|
import Prelude
|
|
|
|
import qualified Control.Concurrent as Base
|
|
|
|
import Control.Concurrent hiding (threadDelay)
|
|
import Data.Time.Clock.Units (Microseconds (..), DiffTime)
|
|
|
|
-- | Like 'Base.threadDelay', but takes a 'DiffTime' instead of an 'Int' microseconds.
|
|
--
|
|
-- NOTE: you cannot simply replace e.g. @threadDelay 1000@ with @sleep 1000@ since those literals
|
|
-- have different meanings!
|
|
sleep :: DiffTime -> IO ()
|
|
sleep = Base.threadDelay . round . Microseconds
|
|
|
|
{-# DEPRECATED threadDelay "Please use `sleep` instead (and read the docs!)" #-}
|
|
threadDelay :: Int -> IO ()
|
|
threadDelay = Base.threadDelay
|