Comments (6)
Just because I'm being dumb… Why do we need this again? async
itself already fast-paths this type of scenario, so the only cost to unconditionally wrapping is a few allocations and a cede
.
from cats-effect.
async
itself already fast-paths this type of scenario
The scenario we are concerned with here is not related to async
actually. It relates to the cost of shifting onto the WSTP because you're not already there, just to obtain a poller that very likely isn't the one you wanted anyway.
from cats-effect.
The scenario we are concerned with here is not related to async actually. It relates to the cost of shifting onto the WSTP because you're not already there, just to obtain a poller that very likely isn't the one you wanted anyway.
I'm definitely confused then. If you're not on the WSTP, then any fast-path to get the current poller would fail, so you'd end up with None
/null
anyway. My understanding of OP is that you wanted something which fast-paths the scenario where you're on the worker thread and you can get the current poller directly, synchronously. Is that not the case?
from cats-effect.
My understanding of OP is that you wanted something which fast-paths the scenario where you're on the worker thread and you can get the current poller directly, synchronously. Is that not the case?
Nope. The OP is exactly like the timers situation: suppose you are trying to cancel a timer. That doesn't mean that you need to get onto the WSTP so that you can safely access a timer heap. All you want to do is see if you have access to a heap on your current thread, and if so, if it is the one you want to manipulate. You don't want access to any heap, you want access to a very specific one if possible, otherwise you can use a fallback mechanism.
Same deal here. You want access to a very specific poller, not any poller, and if you can't immediately get that access, you want to fallback, not get rescheduled.
Currently there is no API that supports this for pollers. For timers there is.
from cats-effect.
How would you envision identifying the poller? Like, you know you want a specific poller, but how would you communicate that to the API?
from cats-effect.
Reference equality? Here's how we do it for timers.
cats-effect/core/jvm/src/main/scala/cats/effect/unsafe/WorkerThread.scala
Lines 294 to 295 in 769a89e
from cats-effect.
Related Issues (20)
- 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
- More efficient monitoring of fibers on virtual threads HOT 1
- Published tutorial older than tutorial.md HOT 1
- OutOfMemoryError when IO.uncancelable is used in recursive function HOT 3
- unsafeToFutureCancelable's cancel future completes before setting the result future's cancellation status HOT 7
- unsafeToFuture fails to raise a second InterruptedException if the exception is handled and retried HOT 6
- Support for V8 JavaScript Engine? HOT 2
- IO.onError is inconsistent with ApplicativeError HOT 3
- `AsyncSpec` failure (ciJS)
- When `IORuntime.global` shuts down, it doesn't shut down the WSTP HOT 1
- Queued but unstarted work on `Dispatcher.sequential` should be cancelable HOT 6
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.