Description
Hi. I'm in the process of writing safe rust bindings for writing Weechat
plugins. Since the Weechat plugin API is inherently asynchronous albeit callback based I had the idea that it would be nice to be able to run rust futures inside of Weechat.
I used async-task to implement an executor that runs on the Weechat event loop rather easily, thanks for the awesome project.
Now to my problem, I have a bunch of Weechat objects that should only be used on the Weechat thread. Since Weechat is in no way thread safe all interaction with Weechat (e.g. printing messages in Weechat) needs to happen inside the Weechat thread.
Since our executor does run on the Weechat thread, futures that run on it should be able to use Weechat objects, but as Weechat isn't thread safe none of them should be marked as Send
.
What I would need to achieve this with async-task is a Task
struct and a
spawn()
method that are not Send
bound. I saw this issue on the async-std tracker, and it seems that I'm not the only one with such a requirement.
I would assume that any C project that runs on some event loop might want to implement an event-loop local executor as well, provided that they are writing rust bindings.
For reference, my prototype executor implementation can be found
here. I'm using a forked version of async-task where I just removed the Send
bounds.