<commit_before>module Utils ( withBackgroundProcessing ) where

import Graphics.UI.Gtk
import Control.Exception
import Control.Concurrent

-- Causes the gtk main loop to yield to other Haskell threads whenever
-- it is idle.  This should be used only when there is
-- compute-intensive activity going on in other threads.
withBackgroundProcessing :: IO a -> IO a
withBackgroundProcessing f =
  bracket 
    (idleAdd (yield >> return True) priorityDefaultIdle)
    timeoutRemove
    (\_ -> f)<commit_msg>use idleRemove instead of timeoutRemove to undo an idleAdd doesn't actually make any difference, but looks neater<commit_after>module Utils ( withBackgroundProcessing ) where

import Graphics.UI.Gtk
import Control.Exception
import Control.Concurrent

-- Causes the gtk main loop to yield to other Haskell threads whenever
-- it is idle.  This should be used only when there is
-- compute-intensive activity going on in other threads.
withBackgroundProcessing :: IO a -> IO a
withBackgroundProcessing f =
  bracket 
    (idleAdd (yield >> return True) priorityDefaultIdle)
    idleRemove
    (\_ -> f)
{'fraction_non_alphanumeric': 0.06346328195829556, 'fraction_numerical': 0.0, 'mean_word_length': 4.134883720930232, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6103185', 'n_tokens_mistral': 293, 'n_tokens_neox': 278, 'n_words': 125}