Waiting for child thread (iron example)

According rust manuals child thread are finished with main thread. This is exactly like other languages and operating system works.
But how do the iron make this?

fn main() {
    fn hello_world(_: &mut Request) -> IronResult<Response> {
        Ok(Response::with((status::Ok, "Hello World!")))

    let _server = Iron::new(hello_world).http("localhost:3000").unwrap();
    println!("On 3000");

There are no any .join or something like this in iron code. And this function stop main thread, but I see "On 3000" in console output.

Thank you.

From the docs of the http method (iron::Iron - Rust):

The thread returns a guard that will automatically join with the parent once it is dropped, blocking until this happens.

So the join seems to happen implicitely.

The Iron implements Drop trait for value are returned by http method. This is it:

impl Drop for Listening {
    fn drop(&mut self) {
        let _ = self._guard.take().map(|g| g.join());

Thank you!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.