HORIZON HASKELLDocslts/ghc-9.14.xd82dee82026-10-12Search names, modules, packages, or :: a typeCtrl K

GHC 9.14.1 · lts/ghc-9.14.x · d82dee8 · 2026-10-12

Moduletime-manager-0.4.0Haskell2010

System.TimeManager

Timeout manager. Since v0.3.0, timeout manager is a wrapper of GHC System TimerManager.

Some caveats of using this package:

  • Only works for GHC

  • Only works with a threaded runtime

  • Users of older versions should check the current semantics.

  • Using 32-bit systems means the max timeout is maxBound :: Int (2147483647) microseconds, which is less than 36 minutes.

  • Using the same Handle in different threads might cause issues in some edge cases. (i.e. using cancel/pause in one thread, and resume in another)

  • 4 types
  • 15 values

Types

5 declarations
newtypenewtype Manager
#

A timeout manager

typetype TimeoutAction = IO ()
#

An action (callback) to be performed on timeout.

datadata Handle
#

A handle used by a timeout manager.

Manager

5 declarations
valueinitialize :: Int -> IO Manager
#

Creating timeout manager with a timeout value in microseconds.

Setting the timeout to zero or lower (<= 0) will produce a defaultManager.

WARNING for Windows users: the precision of extending timeouts is only full "seconds". The provided microseconds will be floored to the first full second. (i.e. initialize 2_500_000 will get extended by 2 seconds on a tickle) This also means timeouts of less than one second will not be extended when using tickle.

valuestopManager :: Manager -> IO ()
#

Deprecated. This function does nothing since version 0.3.0

Obsoleted since version 0.3.0 Is now equivalent to pure ().

valuekillManager :: Manager -> IO ()
#

Deprecated. This function does nothing since version 0.3.0

Obsoleted since version 0.3.0 Is now equivalent to pure ().

Registering a timeout action

2 declarations

Control timeout

4 declarations
valuetickle :: Handle -> IO ()
#

Extending the timeout.

To keep frequent callers cheap, the renewal is rate-limited: it is skipped unless at least a quarter of the timeout (capped at one second) has passed since the timeout was last registered or updated.

Careful: this does NOT reactivate an already paused Handle!

WARNING for Windows users: the precision of extending timeouts is only full "seconds". The provided microseconds will be floored to the first full second. (i.e. initialize 2_500_000 will get extended by 2 seconds on a tickle) This also means timeouts of less than one second will not be extended when using tickle.

valuepause :: Handle -> IO ()
#

Pauses the timeout so you can resume it later. Does not stop it entirely. Use cancel if you want to make sure the action will not be resumed.

To resume a timeout with the same Handle, resume MUST be called. Don't call tickle for resumption.

valuecancel :: Handle -> IO ()
#

Unregistering the timeout.

The timeout can not be resumed. To "resume" the timeout, you need to register again.

Low level

2 declarations

Exceptions

1 declaration