Skip to content

Commit

Permalink
Merge PR #996
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Nov 6, 2024
2 parents bbe6cd1 + af5da00 commit 69bd9a9
Show file tree
Hide file tree
Showing 14 changed files with 410 additions and 145 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,17 @@ jobs:
- "--resolver lts-21 --stack-yaml stack-lts-21.yaml"
- "--resolver lts-20 --stack-yaml stack-lts-20.yaml"
- "--resolver lts-19 --stack-yaml stack-lts-19.yaml"
- "--resolver lts-18 --stack-yaml stack-lts-18.yaml"
exclude:
- os: "macos-latest"
args: "--resolver lts-19 --stack-yaml stack-lts-19.yaml"
- os: "macos-latest"
args: "--resolver lts-18 --stack-yaml stack-lts-18.yaml"

steps:
- name: Clone project
uses: actions/checkout@v4

# Not sure how to have GHC not setup twice
# Something with settings "ghc-version"?
# ["9.8", "9.6", "9.4", "9.2", "9.0", "8.10"]
# ["9.8", "9.6", "9.4", "9.2", "9.0"]
- uses: haskell-actions/setup@v2
name: Setup Haskell Stack
with:
Expand Down
22 changes: 16 additions & 6 deletions auto-update/ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# ChangeLog for auto-update

## 0.2.3

* [#996](https://github.com/yesodweb/wai/pull/996):
Refactored the `Control.Debounce` logic to not leak threads.
* [#996](https://github.com/yesodweb/wai/pull/996):
Added extra `DebounceEdge` options for different types of debouncing.
* `LeadingMute`: Action on first trigger, and ignore any triggers during cooldown
* `TrailingDelay`: First trigger starts cooldown, and
triggers during cooldown extend the cooldown. Action when cooldown expires.

## 0.2.2

* NewAPI: updateThreadName, reaperThreadName, debounceThreadName:
Expand All @@ -14,19 +24,19 @@

* Creating Reaper.Internal to export Reaper constructor.
* Hiding Reaper constructor.
* Add `reaperModify` to the `Reaper` API, allowing workload modification outside
* [#985](https://github.com/yesodweb/wai/pull/985):
Add `reaperModify` to the `Reaper` API, allowing workload modification outside
of the main `reaperAction` loop.
[#985](https://github.com/yesodweb/wai/pull/985)

## 0.1.6

* Add control of activation on leading vs. trailing edges for Control.Debounce
[#756](https://github.com/yesodweb/wai/pull/756)
* [#756](https://github.com/yesodweb/wai/pull/756):
Add control of activation on leading vs. trailing edges for Control.Debounce

## 0.1.5

* Using the Strict and StrictData language extensions for GHC >8.
[#752](https://github.com/yesodweb/wai/pull/752)
* [#752](https://github.com/yesodweb/wai/pull/752):
Using the Strict and StrictData language extensions for GHC >8.

## 0.1.4.1

Expand Down
5 changes: 5 additions & 0 deletions auto-update/Control/AutoUpdate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ data UpdateSettings a = UpdateSettings
--
-- @since 0.1.0
, updateThreadName :: String
-- ^ Label of the thread being forked.
--
-- Default: @"AutoUpdate"@
--
-- @since 0.2.2
}

-- | Generate an action which will either read from an automatically
Expand Down
21 changes: 14 additions & 7 deletions auto-update/Control/Debounce.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,27 @@
--
-- @since 0.1.2
module Control.Debounce (
-- * Type
-- * Creation
mkDebounce,

-- * Settings
DI.DebounceSettings,
defaultDebounceSettings,

-- * Accessors
-- ** Accessors
DI.debounceFreq,
DI.debounceAction,
DI.debounceEdge,
DI.debounceThreadName,

-- ** Edge types
DI.leadingEdge,
DI.leadingMuteEdge,
DI.trailingEdge,

-- * Creation
mkDebounce,
DI.trailingDelayEdge,
) where

import Control.Concurrent (newEmptyMVar, threadDelay)
import Control.Concurrent (newMVar, threadDelay)
import qualified Control.Debounce.Internal as DI

-- | Default value for creating a 'DebounceSettings'.
Expand All @@ -56,8 +60,11 @@ defaultDebounceSettings =

-- | Generate an action which will trigger the debounced action to be performed.
--
-- /N.B. The generated action will always immediately return, regardless of the 'debounceFreq',/
-- /as the debounced action (and the delay\/cooldown) is always performed in a separate thread./
--
-- @since 0.1.2
mkDebounce :: DI.DebounceSettings -> IO (IO ())
mkDebounce settings = do
baton <- newEmptyMVar
baton <- newMVar ()
DI.mkDebounceInternal baton threadDelay settings
Loading

0 comments on commit 69bd9a9

Please sign in to comment.