2 comments

  • pjmlp 13 hours ago
    This looks kind of outdated, especially since we are on C++23 as latest approved standard, and co-routines would be a better approach since C++20.

    Also how is the supposed Swift rewrite going on?

    • jwolfe 7 hours ago
      • pjmlp 4 hours ago
        Thanks!
    • hiyfsch 8 hours ago
      Just because coroutines exist doesn’t mean everything should use them for concurrency.

      Why would it be better? It’s pretty easy to set up threads in general.

      • Rohansi 7 hours ago
        Threads use more system resources than coroutines so it can be a big deal when you can potentially have thousands of them running.
      • alfiedotwtf 4 hours ago
        The management to handle Threading and IO and not get it wrong is pretty high unless you’re using something like Rust because it guarantees you’re safe, vs letting the routine runtime management handle everything for you for free
        • whizzter 1 hour ago
          Nah, coroutines/async/etc often lives in various threads (ie, the workers can schedule one of them on different threads during the lifetime and they live concurrently), so you still have all the issues of threading (+ new ones since things like thread-local variables aren't reliable if an async/coroutines moves threads between calls).

          The main benefit is not having the cost of threads, f.ex. a default thread on Windows has something like 500k of stack iirc, scale that to 10000 concurrent requests and you're looking at 5gb of memory _just for stacks_, compared to a couroutine,etc that has perhaps a few kb's of usage (even if in deep stack-traces).

          This is why we have stuff like io_uring these days, the bottleneck moved to the kernel calls (especially with Spectre style attacks) when concurrent costs in the applications went down.

          • menaerus 35 minutes ago
            > Nah, coroutines/async/etc often lives in various threads (ie, the workers can schedule one of them on different threads during the lifetime and they live concurrently), so you still have all the issues of threading (+ new ones since things like thread-local variables aren't reliable if an async/coroutines moves threads between calls).

            In cooperative scheduling how is it possible to have two coroutines running concurrently?

          • ddorian43 17 minutes ago
            > aren't reliable if an async/coroutines moves threads between calls

            Then just don't move them between threads and you're good with thread locals, no?

    • rnagulapalle 3 hours ago
      [flagged]
  • jen20 14 hours ago