lock

Single Threaded: Summation of a Vector

What is the fastest way to add the elements of a std::vector?. A question which I will pursue in the next posts. I use the single threaded addition as reference number. In further posts I discuss atomics, locks, and thread local data.

Read more
Tags: atomics, lock
Comments 6Views: 2737

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
Comments 5Views: 4768

Ongoing Optimization: Locks and Volatile with CppMem

The easiest way to solve the undefined behaviour in the post Ongoing Optimization: Unsynchronized access is, to use a lock.

Read more
Add CommentViews: 1259

Reader-Writer Locks

With C++14 came reader-writer locks. The idea is straightforward and promising. Arbitrary reading threads can access the critical region at the same time, but only one thread is allowed to write.

Read more
Tags: lock
Comments 3Views: 2684

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
Comments 17Views: 2274

Support my blog by buying my E-book

Latest comments

Modernes C++

Subscribe to the newsletter

Including two chapters of my e-book
Introduction and Multithreading

Blog archive

Source Code

Visitors

Today 2127

All 228141

Currently are 167 guests and no members online