Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the current Scheduler api? #3356

Open
He-Pin opened this issue Jan 11, 2023 · 4 comments
Open

Update the current Scheduler api? #3356

He-Pin opened this issue Jan 11, 2023 · 4 comments

Comments

@He-Pin
Copy link

He-Pin commented Jan 11, 2023

Hi I am still new on cats-effect ,but I think the current api of Scheduler can be updated with :

trait Scheduler {
  type TimerId= Long

  def scheduleOnce(delay: FiniteDuration, task: Runnable): TimerId

   def scheduleWithFixedDelay(initialDelay:FiniteDuration, delay: FiniteDuration, task: Runnable):TimerId

   def scheduleAtFixedRate(initialDelay:FiniteDuration, delay: FiniteDuration, task: Runnable):TimerId

   def cancel(timerId:TimerId):Boolean

   def clock(): Clock
   ...
  ...
}

And seems like the only way to cancel the current scheduled task is by call the returning Runnable with the current Scheduler api?

As I'm starting using vertx these days, and I think the cats.effect.unsafe.WorkerThread can do the scheduling too, just as Netty's Eventloop does, which employed an PriorityQueue to do that.

@armanbilge
Copy link
Member

And seems like the only way to cancel the current scheduled task is by call the returning Runnable with the current Scheduler api?

That's correct. Unfortunately, we cannot change the API at this point due to compatibility constraints.


As I'm starting using vertx these days, and I think the cats.effect.unsafe.WorkerThread can do the scheduling too, just as Netty's Eventloop does, which employed an PriorityQueue to do that.

It can, and it will very soon! See this PR:

@He-Pin
Copy link
Author

He-Pin commented Jan 11, 2023

And then, a user can using a HashWheelTimer which turn out the timeout as an event and send to the workerThread's taskQueue.

Update:
Thanks, I will take sometime to learn from this new PR.

@lqhuang
Copy link

lqhuang commented Jan 29, 2023

That's correct. Unfortunately, we cannot change the API at this point due to compatibility constraints.

@armanbilge May I have a question about when or what conditions are satisfied, then we could make improvements and break compatibility constraints.

Thanks!

@armanbilge
Copy link
Member

May I have a question about when or what conditions are satisfied, then we could make improvements and break compatibility constraints.

When we are working on Cats Effect 4, which would be a major, breaking change. But there are no concrete plans for this at the moment. It would probably happen around the same time as Cats 3, which is also rather hypothetical.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants