1. 47
  1. 17

    https://twitter.com/m_ou_se/status/1557742789693427712 has an additional writeup. Using VecDeque as a Read/Write circular buffer is cool.

    1. 16

      Having scoped threads in std is great. First language, AFAIK, with this kind of structured concurrency in it’s stdlib. Definitely the first that also statically prevents data races.

      1. 3

        Yeah I agree!

        I was wondering - what remains missing from “structured concurrency”? Just looking again at [1] I can see cancellation, error propagation and being able to create and pass around and inject the scope object s elsewhere (for spawning background tasks that outlive whatever calls s.spawn) as being things that I can’t immediately see as being possible or not. Does anyone know - would these already be possible with what’s there now?

        [1] https://vorpus.org/blog/notes-on-structured-concurrency-or-go-statement-considered-harmful

        1. 3

          Error propagation is already possible (as (Scoped)JoinHandle<T>::join() returns whatever was returned by the scoped/spawned routine).

          1. 1

            Lifetimes stop you from exfiltrating the scope handle outside the callback, yes. You can’t mem::swap it somewhere because the destination would need to have the exact same lifetime (and therefore, created from inside the callback).