Multithreading 101: Concurrency Primitives From Scratch - Arvid Gerstmann - Meeting C++ 2019

Поділитися
Вставка
  • Опубліковано 20 гру 2019
  • Multithreading 101: Concurrency Primitives From Scratch - Arvid Gerstmann - Meeting C++ 2019
    Slides: meetingcpp.com/mcpp/slides
  • Наука та технологія

КОМЕНТАРІ • 3

  • @BradDavis_vr
    @BradDavis_vr 4 роки тому +3

    The code at 29:31 has a flaw. It attempts to wait for waitMs milliseconds, regardless of how many times you've entered the loop. If you get lots of spurious wake ups, then you can wait for an arbitrarily long time before timing out.

  • @pazdziochowaty
    @pazdziochowaty 4 роки тому

    This reminds me of the implementation of QMutex from Qt. There is also a fast path based on spinlock and then fallback to pthreads/futex/WaitForSingleObject/semaphores depending on operating system. They do not fall back to std::mutex/std::condition_variable because Qt started when they were not part of the C++ standard (the first version might actually even predate 1998 standard).
    However if you wanted to base the implementation purely on the standard without OS-specific code I do not get why bother with futex abstraction at all instead of just using std::condition_variable as the suspend path in your fast mutex class

  • @PaulJurczak
    @PaulJurczak 4 роки тому

    At 4:43: why call a data member "m_lock" and have to add an explanation what it means, instead of self-explanatory "isLocked" or "is_locked"?