Skip to main content

Timeline for How does a blocking call work?

Current License: CC BY-SA 4.0

11 events
when toggle format what by license comment
Jun 18, 2021 at 22:50 vote accept msmoiz
Jun 18, 2021 at 3:41 answer added Nicol Bolas timeline score: 4
Jun 17, 2021 at 22:13 comment added Robert Harvey But it's not necessarily a mutex, or even another thread. Some async systems, like the one in C#, sign on the remainder of the method as a continuation running on the same thread. See here for an explanation.
Jun 17, 2021 at 22:00 comment added Robert Harvey The distinction can be thought of as a new thread running the background work, which communicates completion to the original blocked thread. A mutex would accomplish this quite nicely.
Jun 17, 2021 at 21:57 comment added Robert Harvey Note the #include <mutex> at line 38, which is the first mechanism I thought of that might accomplish this.
Jun 17, 2021 at 21:56 comment added msmoiz Fair point - I am trying to understand the distinction (that exists in my mind, at least) between blocking calls that are doing things (e.g., adding numbers) vs. blocking calls that are not doing any work of their own but are instead waiting for work to finish elsewhere.
Jun 17, 2021 at 21:53 comment added Robert Harvey What, exactly, is the mechanism under the hood that accomplishes this, I'm not sure. It could be as simple as a callback. In any case, the source code for std::future is here, if you're so inclined.
Jun 17, 2021 at 21:47 comment added Robert Harvey So your .wait() call could merely be considered an ordinary method call, in this context. What is it waiting for? The result of the promise/future to arrive.
Jun 17, 2021 at 21:47 review First posts
Jun 18, 2021 at 2:12
Jun 17, 2021 at 21:46 comment added Robert Harvey Note that an ordinary method/function call, in the absence of a promise/future and .wait(), is also considered a "blocking call."
Jun 17, 2021 at 21:43 history asked msmoiz CC BY-SA 4.0