Giter Site home page Giter Site logo

Comments (6)

djspiewak avatar djspiewak commented on June 27, 2024

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.

armanbilge avatar armanbilge commented on June 27, 2024

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.

djspiewak avatar djspiewak commented on June 27, 2024

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.

armanbilge avatar armanbilge commented on June 27, 2024

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.

djspiewak avatar djspiewak commented on June 27, 2024

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.

armanbilge avatar armanbilge commented on June 27, 2024

Reference equality? Here's how we do it for timers.

private[unsafe] def ownsTimers(timers: TimerHeap): Boolean =
sleepers eq timers

from cats-effect.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.