mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-28 09:42:40 +01:00
Wait for spawned thread
A spawned thread doesn't block the main thread exiting unless explicitly joined. The demo as written in the guide simply exits immediately at the moment.
This commit is contained in:
parent
30bdf9cb5e
commit
232aba2080
@ -79,13 +79,14 @@ fn index(req: HttpRequest) -> &'static str {
|
||||
}
|
||||
|
||||
fn main() {
|
||||
# thread::spawn(|| {
|
||||
# let child = thread::spawn(|| {
|
||||
HttpServer::new(
|
||||
|| Application::new()
|
||||
.resource("/", |r| r.f(index)))
|
||||
.bind("127.0.0.1:8088").expect("Can not bind to 127.0.0.1:8088")
|
||||
.run();
|
||||
# });
|
||||
});
|
||||
# child.join().expect("failed to join server thread");
|
||||
}
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user