Closed harshakhmk closed 1 year ago
The event-loop of calloop is designed to be a single-threaded event loop, and as such making it threadsafe is currently a non-goal.
Furthermore calloop uses internally its own sleep-wake mechanisms, so mixing it with other runtimes like tokio should be made with extreme care to avoid conflict.
What are you actually trying to achieve?
The event-loop of calloop is designed to be a single-threaded event loop, and as such making it threadsafe is currently a non-goal.
Furthermore calloop uses internally its own sleep-wake mechanisms, so mixing it with other runtimes like tokio should be made with extreme care to avoid conflict.
What are you actually trying to achieve?
I just wanted to add functions with timer to eventloop and execute them periodically for that I have wrapped eventloop code inside tokio loop
But, why are you trying to mix tokio and calloop?
Calloop is an event loop by itself, using it to run periodical callbacks doesn't require tokio at all, and I'm pretty sure tokio can also be used to run periodical callbacks by itself.
I combined tokio & calloop to have periodic function calling, but using TimeoutAction:: ToDuration() can also be used to achieve periodic function calling, without the need of tokio?
Yes, this mechanism is exactly designed to create timers to reprogram themselves automatically, such as invoking the same callback every X seconds.
Yes, this mechanism is exactly designed to create timers to reprogram themselves automatically, such as invoking the same callback every X seconds.
That is what I was looking for, thanks
Hi, I was experimenting with calloop to run a task periodically, for that I added a method with to eventloop and execute it after sometime, I wrapped the eventloop inside tokio multi-threaded code, but getting an error Rc<calloop::loop_logic::LoopInner<'a, ()>> cannot be shared between threads safely. It would be very helpful, if someone could provide how to make calloop object be shared across threads safely The multi threaded tokio code looks like `tokio::spawn(async move { loop { tokio::time::sleep(idle_duration).await;
});`