-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Updatable one-shot timer polled with STM
--   
--   This library lets you create a one-shot timer, poll it using STM, and
--   update it to ring at a different time than initially specified.
--   
--   It uses GHC event manager timeouts when available (GHC 7.2+,
--   <tt>-threaded</tt>, non-Windows OS), yielding performance similar to
--   <tt>threadDelay</tt> and <tt>registerDelay</tt>. Otherwise, it falls
--   back to forked threads and <tt>threadDelay</tt>.
--   
--   <ul>
--   <li><i>0.1.1.2 (2025-05-08)</i></li>
--   </ul>
--   
--   <ul>
--   <li>Remove a call to ensureIOManagerIsRunning, for consistency with
--   System.Timeout</li>
--   <li>Adjust timings in the testsuite to fix intermittent failure in the
--   non-threaded RTS case.</li>
--   </ul>
--   
--   <ul>
--   <li><i>0.1.1 (2014-09-14)</i></li>
--   </ul>
--   
--   <ul>
--   <li>Add tryWaitDelayIO, improve performance for certain cases of
--   <tt>newDelay</tt> and <tt>updateDelay</tt>, and improve example.</li>
--   </ul>
@package stm-delay
@version 0.1.1.2


-- | One-shot timer whose duration can be updated. Think of it as an
--   enhanced version of <a>registerDelay</a>.
--   
--   This uses <a>GHC.Event</a> when available (GHC 7.2+,
--   <tt>-threaded</tt>, non-Windows OS). Otherwise, it falls back to
--   forked threads and <a>threadDelay</a>.
module Control.Concurrent.STM.Delay

-- | A <a>Delay</a> is an updatable timer that rings only once.
data Delay

-- | Create a new <a>Delay</a> that will ring in the given number of
--   microseconds.
newDelay :: Int -> IO Delay

-- | Set an existing <a>Delay</a> to ring in the given number of
--   microseconds (from the time <a>updateDelay</a> is called), rather than
--   when it was going to ring. If the <a>Delay</a> has already rung, do
--   nothing.
updateDelay :: Delay -> Int -> IO ()

-- | Set a <a>Delay</a> so it will never ring, even if <a>updateDelay</a>
--   is used later. If the <a>Delay</a> has already rung, do nothing.
cancelDelay :: Delay -> IO ()

-- | Block until the <a>Delay</a> rings. If the <a>Delay</a> has already
--   rung, return immediately.
waitDelay :: Delay -> STM ()

-- | Non-blocking version of <a>waitDelay</a>. Return <a>True</a> if the
--   <a>Delay</a> has rung.
tryWaitDelay :: Delay -> STM Bool

-- | Faster version of <tt><a>atomically</a> . <a>tryWaitDelay</a></tt>.
--   See <a>readTVarIO</a>.
--   
--   Since 0.1.1
tryWaitDelayIO :: Delay -> IO Bool
instance GHC.Classes.Eq Control.Concurrent.STM.Delay.Delay
