You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm looking for a way to periodically execute a function inside a ServerActor. This should continue indefinitely until the ServerActor is terminated. In Java, this is typically done by creating a new thread and running a timer. Even in the Quasar tests for Actor, sleep() is used to cause a delay between function calls, which of course creates a new thread.
My concern is that if I instantiate ServerActors using spawn() rather than spawnThread(), each instance will run in a fiber. However, if I put a sleep() inside one of the methods to handle scheduling, I now have both a fiber and a thread associated with this ServerActor. This seems risky in regard to scaling.
Is there a standard way to implement lightweight task scheduling using fibers in Quasar?
The text was updated successfully, but these errors were encountered:
The state of the timer ultimately is stored in your fiber scheduler instance. You can also create a "timer actor" that sends messages at the right period.
I'm looking for a way to periodically execute a function inside a ServerActor. This should continue indefinitely until the ServerActor is terminated. In Java, this is typically done by creating a new thread and running a timer. Even in the Quasar tests for Actor, sleep() is used to cause a delay between function calls, which of course creates a new thread.
https://github.com/puniverse/quasar/blob/master/quasar-actors/src/test/java/co/paralleluniverse/actors/ActorTest.java#L185
Coming from the Erlang/Elixir world, I have been happy with an implementation like this, where the GenServer passes itself a message periodically.
https://stackoverflow.com/a/32097971/1289597
My concern is that if I instantiate ServerActors using spawn() rather than spawnThread(), each instance will run in a fiber. However, if I put a sleep() inside one of the methods to handle scheduling, I now have both a fiber and a thread associated with this ServerActor. This seems risky in regard to scaling.
Is there a standard way to implement lightweight task scheduling using fibers in Quasar?
The text was updated successfully, but these errors were encountered: