Skip to content

send feature not working #372

Answered by khvzak
ezenkico asked this question in Q&A
Feb 28, 2024 · 1 comments · 4 replies
Discussion options

You must be logged in to vote

An example of using channels

#[tokio::main]
async fn main() -> mlua::Result<()> {
    let chunk_tx = {
        let (send, mut recv) =
            tokio::sync::mpsc::unbounded_channel::<(String, Sender<LuaResult<()>>)>();
        let rt = Builder::new_current_thread().enable_all().build().unwrap();
        std::thread::spawn(move || {
            rt.block_on(async {
                let lua = Lua::new();
                while let Some((chunk, res_tx)) = recv.recv().await {
                    let res = lua.load(chunk).exec_async().await;
                    res_tx.send(res).unwrap();
                }
            });
        });
        send
    };

    let (res_tx, res_rx) = tokio::sync::o…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@ezenkico
Comment options

@khvzak
Comment options

@khvzak
Comment options

Answer selected by ezenkico
@ezenkico
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants