In my application I need to write a scheduled task which iterates every minute, which what code it runs need to be depended on some output last time it runs.
Then I have an ownership problem. No matter it is a piece of data or a channel, seem I need somebody else than the scheduler to hold the ownership so its lifetime can persist through. In a crate clokwerk the way I run a task is passing a closure to the scheduler and it happens cannot let data persists.
Is there any suggestions on how to implement this?
Generally you should try to keep the data owned by one task only. Consider using message passing to communicate with that task if you need some information about the data the task owns.
yes i agree with that. however i have no idea how to pass a channel receiver to such recurring task.
As far as i imagine, if I pass a channel receiver to a task, it will takeover the ownership and dissipate after the task complete. How can I pass the dissipated channel receiver to the next instance of such recurring task?