Comments (3)
So, there is an idempotency check (specifically applied here). From a performance standpoint, I'm pretty sure AtomicBoolean
is an order of magnitude faster than raw synchronization (especially when uncontested), but even beyond that, we could do even better with a method handle and a switch point if we really wanted to make it that fast.
The problem is that if IO
doesn't do this, it either has to capture an ExecutionContext
(in order to use reportFailure
) or just swallow the error altogether, neither of which seem like particularly good solutions relative to the rest of the design.
But all that aside… I tend to agree that the law is too restrictive. It basically means that implementors can only implement their types in this way, and I don't think that's what we want to say. So I think you're right that we should remove the law and add it as a test specifically for IO
.
from cats-effect.
Well, yeah, on top of Java 8 that getAndSet
operation is pretty fast, using platform intrinsics and if you do it once "per program" it's not a problem. Also when dealing with say a Scala Promise
, it has trySuccess
baked in.
So yes, it's not IO's implementation I'm complaining about, but this law :-)
It would have been helpful to specify an Either in that law ... such that we could specify equivalence with raiseError(ex)
or never
. Such a law would still disallow blowing the current call-stack for example.
from cats-effect.
It would have been helpful to specify an Either in that law ... such that we could specify equivalence with raiseError(ex) or never. Such a law would still disallow blowing the current call-stack for example.
Hmm, that's an interesting idea, though I'm not sure how many implementation flaws that would actually catch. A bigger problem though is that the current Eq[IO[A]]
implementation I'm using in the laws is unable to check equivalence with never
. I haven't actually looked at how Monix's tests do that…
from cats-effect.
Related Issues (20)
- `CallbackStack#pack` can double-count removals when called concurrently HOT 5
- dispatcher document warning about bounded queue
- sequential dispatcher: race condition in release `step` causes disorder
- Delaying a task to be run far into the future can prevent concurrently scheduled tasks from running HOT 3
- Document stack-safety requirements of typeclasses
- `Dispatcher#unsafeRunTimed` should also `cancel()` if `Await.result` is `interrupt`ed HOT 7
- Flakiness in `SchedulerSpec` HOT 1
- Flakiness in `SupervisorSpec` HOT 1
- Dispatcher sequential runs queued tasks concurrently when closing HOT 2
- Flakiness in `IOSpec` HOT 1
- better handling of callbacks that might throw in `CallbackStack` HOT 1
- Allow overriding how fatal errors are printed HOT 7
- Improve `MonadCancel` scaladoc HOT 4
- Cancelling `Async` queue `take` makes other `take` hang HOT 5
- `IO#asyncCheckAttempt` is inconsistent with `Async#asyncCheckAttempt`
- Improve contributor documentation HOT 3
- Add (best-effort) stealing API to polling system
- Add API to polling system to attempt to get current poller without shifting HOT 6
- More efficient monitoring of fibers on virtual threads HOT 1
- Published tutorial older than tutorial.md HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cats-effect.