Commit Graph

6 Commits

Author SHA1 Message Date
Cristian Díaz
99da71ff51 Add throttle overloads that take types (#1101)
Co-authored-by: Cristian Díaz <cristian.diaz@monstar-lab.com>
2022-05-19 11:01:29 -04:00
stephencelis
b3edfcd3a4 Run swift-format 2021-07-28 18:58:37 +00:00
André Pacheco Neves
d42b471cbd Fix Effect.throttle delayed value shared state cleanup (#683)
Effect.throttle didn't clean up `throttleValues` shared state on the
delayed values path, leading to the first value strategy
(`latest: false`) to return incorrect (old) values on some scenarios.

## Changes

- Add missing `throttleValues[id]` clean up in `Effect.throttle` delayed
value path.
2021-07-28 14:50:49 -04:00
stephencelis
b809888a5b Run swift-format 2021-07-22 17:45:38 +00:00
André Pacheco Neves
65f1fa043f Fix Effect.throttle data races and scheduler value return (#669)
* Fix `Effect.throttle` data races and scheduler value return

The `Effect.throttle` operator had multiple data races when updating
`throttleTimes` and `throttleValues` shared state, because:

1. `Effect.throttle` can be called from any scheduler.
2. The internal `flatMap` runs on the current chain scheduler, but the
throttled (delayed) value runs on the passed in `scheduler` parameter
(which can be different).

By protecting shared state with a lock (similar to the cancellables'),
these data races should be addressed.

Additionally, the `Effect.throttle` should return all values in the
`scheduler` passed in, so that the API contract is honored and values
come from where callers expect them to.

## Changes

- Add new `throttleLock` `recursive lock to protect `throttleTimes`
and `throttleValues` shared state in `Effect.throttle` operator.

- Ensure all values in `Effect.throttle` come from the passed in
`scheduler`.

* Fix `Effect.throttle` tests, Use `sync` lock helper
2021-07-22 13:32:36 -04:00
Stephen Celis
e7dda73c35 Fix Effect.throttle (#654)
* Fix Effect.throttle

Fixes #540.

* Simplify

* Publicize
2021-07-13 11:06:51 -04:00