diff options
author | Andreas Voellmy <andreas.voellmy@gmail.com> | 2013-01-07 20:04:36 -0500 |
---|---|---|
committer | Johan Tibell <johan.tibell@gmail.com> | 2013-02-11 21:38:07 -0800 |
commit | cbe3c39e18786bbec437671578ce94a1770b2aff (patch) | |
tree | 05af4977af021693c2757e4ac1b7f2d892892aab /libraries | |
parent | f0d1822f8ab6864b5d4bc40d2984dabfb6984e59 (diff) | |
download | haskell-cbe3c39e18786bbec437671578ce94a1770b2aff.tar.gz |
Add some commentary in GHC.Event.Manager to the explain the poll loop.
Diffstat (limited to 'libraries')
-rw-r--r-- | libraries/base/GHC/Event/Manager.hs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/libraries/base/GHC/Event/Manager.hs b/libraries/base/GHC/Event/Manager.hs index 5c0ac0a6e0..8fc42e5682 100644 --- a/libraries/base/GHC/Event/Manager.hs +++ b/libraries/base/GHC/Event/Manager.hs @@ -246,6 +246,14 @@ loop mgr@EventManager{..} = do Releasing -> putMVar emLock () _ -> cleanup mgr +-- | To make a step, we first do a non-blocking poll, in case +-- there are already events ready to handle. This improves performance +-- because we can make an unsafe foreign C call, thereby avoiding +-- forcing the current Task to release the Capability and forcing a context switch. +-- If the poll fails to find events, we yield, putting the poll loop thread at +-- end of the Haskell run queue. When it comes back around, we do one more +-- non-blocking poll, in case we get lucky and have ready events. +-- If that also returns no events, then we do a blocking poll. step :: EventManager -> IO State step mgr@EventManager{..} = do waitForIO |