Skip to content

Help needed: how to use stick in tokio? #45

Description

@hkoosha

Hi!
I want one thread to read stick events, another one to pick up the latest read event and send it off on a network socket. For networking purposes I'm using tokio, not pasts crate.

The issue is, I can't spawn a task with tokio as Controller has an Rc inside and rust is unhappy about it not being Send.

Here's the gist of the code:

let mut state = State::new(...);
let mut controller = get_ctl().await;
tokio::spawn(async move {  // => error here => future created by async block is not `Send`
    loop {
        let event = (&mut controller).await; // => also error => has type `Controller` which is not `Send`
        state.event(event);
    }
});

(Please forgive any stupid usage of rust / tokio / stick / async, I'm a newbie to both rust and async!)

Can you please guide me on how to achieve this? how should I send a controller through an async task? does this require fundamental changes to stick to use Arc?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestquestionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions