Re:Notes on structured concurrency, or: Go statement conside...
by stouset on Wednesday April 25, 2018 @10:21PM
(#16928292)
I don’t think there’s any reason a nursery has to have a static lifetime.
[ Parent
| on HN ]
Re:Notes on structured concurrency, or: Go statement conside...
by eridius on Thursday April 26, 2018 @12:13AM
(#16928743)
The description of the nursery is you can pass it around wherever you like. More generally, this concept seems to have been designed in a language without lifetimes. You obviously can have a scoped threadpool without a 'static lifetime, but if you want to pass it around to arbitrary locations then you do.
Re:Notes on structured concurrency, or: Go statement conside...
by twic on Thursday April 26, 2018 @08:33AM
(#16931232)
I think the whole point of the nursery's design is that you can create and destroy them during the life of your program, and that destroying them forms a barrier where the owner of the nursery waits for its children to finish. Having a nursery with a static lifetime in Rust would therefore be pointless, as it would live until the end of the program.
Re:Notes on structured concurrency, or: Go statement conside...
by eridius on Thursday April 26, 2018 @11:50AM
(#16932960)
I think you misunderstand. I'm talking about writing something like `ScopedThreadpool<'static>`, which means any external data referenced by the threadpool must have a static lifetime (or rather, it means the ScopedThreadpool cannot reference anything on the stack, because that would prevent you from e.g. returning it to your caller or passing it to another thread). The ScopedThreadpool itself can be created and destroyed whenever.
Re:Notes on structured concurrency, or: Go statement conside...
by arghwhat on Thursday April 26, 2018 @10:15AM
(#16932055)
I would definitely consider the "nursery" to be a newly created device (threadpool/reactor/...), where the resources used by the functions run in this "nursery" only has a lifetime requirement equal to the nursery.