Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Is it possible to use theads code?#25

Answeredbyjmjoy
mrceperka asked this question inQ&A
Discussion options

Hello,

I was wondering if threads or evenasync could be used in rust code. I guess that for async, runtime is needed so -> no, but threads -> maybe? :D

I don't know rust much, sorry.

Thanks for this repository btw 🙏

You must be logged in to vote
Answered by jmjoyAug 2, 2021

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

jmjoy
Aug 2, 2021
Maintainer

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.

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

Thanks for the answer, that was fast :) I've missed that example, sorry.

Answer selected bymrceperka
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@mrceperka@jmjoy

[8]ページ先頭

©2009-2025 Movatter.jp