Description
Continuing discussion from #14:
(also, if you're aiming for feature-parity, I think
task_locals
are something that can't currently be implemented in a reasonable fashion without support from the executor, so it may make sense to add support for them, but I'm not sure what level of feature-parity you're trying to achieve right now, so won't open an issue straight away -- I can do if you want)
I'm curious - what do you need task-locals for? My guess is for logging, but thought I'd ask anyway.
In theory, task-locals can be implemented without support from the executor as a separate library. Imagine you wrap spawned futures in something like:
let task = Task::spawn(SupportTaskLocals(future));
Then,
SupportTaskLocals
puts task-locals inside thread-locals every time the future is polled.
Well, logging is indeed one of the use cases of task-locals, but I also was coming from https://github.com/Ekleog/erlust ; where, to best emulate erlang from rust, I needed a way to store the return-path to the current actor as a task-local -- as well as the currently configured way to reach other actors, in order to enable cross-process transparency as well as network transparency. Disclaimer though: I haven't really touched that code for a while, and am not yet sure whether I think it's a good idea any longer anyway, so…
As for the SupportTaskLocals
solution… the main issue is that then, the user needs to remember to manually do it on each task spawn if they want to be able to use inter-actor communication from that task; while something supported by the executor (behind a feature flag maybe?) would make it seamless.