mutex

The Null Object Pattern

A Null Object encapsulates a do nothing behavior inside an object. It is often pretty comfortable to use a neutral object.

Read more
Tags: lock, mutex
Views: 5573

Dining Philosophers Problem II

In the last post "Dining Philosophers Problem I", Andre Adrian started his analysis of the classical dining philosophers' problem. Today, he uses atomics, mutexes, and locks.

Read more
Views: 5110

C++ Core Guidelines: Sharing Data between Threads

If you want to have fun with threads, you should share mutable data between them. In order to get no data race and, therefore, undefined behavior, you have to think about the synchronization of your threads.

Read more
Tags: lock, mutex
Views: 103605

Thread-Safe Initialization of a Singleton

There are a lot of issues with the singleton pattern. I'm totally aware of that. But the singleton pattern is an ideal use case for a variable, which has only to be initialized in a thread-safe way. From that point on you can use it without synchronization. So in this post, I discuss different ways to initialize a singleton in a multithreading environment. You get the performance numbers and can reason about your uses cases for the thread-safe initialization of a variable.

Read more
Views: 355197

Prefer Locks to Mutexes

If the previous post showed something, it's that you should use mutexes with great care. That's why you should wrap them in a lock.

Read more
Tags: lock, mutex
Views: 150527

The Risks of Mutexes

Usage of mutexes seems extremely simple. There is a critical section in the code, which can only be accessed by a single thread at any point of time. It's ensured by a mutex m. The calls m.lock() and m.unlock() guarantee this exclusivity. But, the devil is in the details.

Read more
Tags: mutex
Views: 36254

Mentoring

Stay Informed about my Mentoring

 

English Books

Course: Modern C++ Concurrency in Practice

Course: C++ Standard Library including C++14 & C++17

Course: Embedded Programming with Modern C++

Course: Generic Programming (Templates)

Course: C++ Fundamentals for Professionals

Interactive Course: The All-in-One Guide to C++20

Subscribe to the newsletter (+ pdf bundle)

All tags

Blog archive

Source Code

Visitors

Today 2258

Yesterday 5317

Week 2258

Month 146429

All 11627583

Currently are 206 guests and no members online

Kubik-Rubik Joomla! Extensions

Latest comments