tomaka / rouille

Web framework in Rust
Apache License 2.0
1.09k stars 105 forks source link

Add Server.poll_timeout method #203

Closed dbr closed 5 years ago

dbr commented 5 years ago

As per #200 I was looking for a way to have Rouille run in a thread, in a way which I could interrupt when the application shutdown.

Just calling poll in a loop seemed very wasteful. For my purposes just calling poll with a short (~10ms or so) sleep was okay, but seemed like it'd be easy/useful to add a poll_timeout method consistent with tiny_http's recv_timeout

adnanademovic commented 5 years ago

I've had the same need for a server, and was about to make the same PR. It seems like the simplest and cleanest solution to being able to shut down the server from the same thread. For the moment, I did the same delay-based solution, but it's a needless waste, as the main reason for using rouille is the fact that it's so snappy and lightweight!!