Skip to content

Is it possible to use theads code? #25

Answered by jmjoy
mrceperka asked this question in Q&A
Discussion options

You must be logged in to vote

You can spawn threads or async coroutine, spawn thread: https://doc.rust-lang.org/std/thread/fn.spawn.html, spawn coroutine using tokio: https://docs.rs/tokio/1.9.0/tokio/fn.spawn.html.

If you are using NTS mode, spawn threads or coroutine in module init function will be persistent, spawn threads or coroutine in request lifetime will be drop after request finished.

You can reference to http server example: https://github.com/jmjoy/phper/tree/master/examples/http-server.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@mrceperka
Comment options

Answer selected by mrceperka
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