intermediate

Quick Q: Do mutexes guarantee ordering of acquisition?

Quick A: They do not.

Recently on SO:

Do mutexes guarantee ordering of acquisition?

Known problem. C++ mutexes are thin layer on top of OS-provided mutexes, and OS-provided mutexes are often not fair. They do not care for FIFO.

The other side of the same coin is that threads are usually not pre-empted until they run out of their time slice. As a result, thread A in this scenario was likely to continue to be executed, and got the mutex right away because of that.

Overload 133 is now available

ACCU’s Overload journal of April 2016 is out. It contains the following C++ related articles.

Overload 132

From the journal:

Dogen: The Package Management Saga
How do you manage packages in C++? Marco Craveiro eventually discovered Conan after some frustrating experiences. by Marco Craveiro

QM Bites – Order Your Includes (Twice Over)
Header includes can be a shambles. Matthew Wilson encourages us to bring some order to the chaos. by Matthew Wilson

A Lifetime In Python
Resource management is important in any language. Steve Love demonstrates how to use context managers in Python. by Steve Love

Deterministic Components for Distributed Systems
Non-deterministic data leads to unstable tests. Sergey Ignatchenko considers when this happens and how to avoid it. by Sergey Ignatchenko

Programming Your Own Language in C++
Scripting languages allow dynamic features easily. Vassili Kaplan writes his own in C++ allowing keywords in any human language. by Vassili Kaplan

Concepts Lite in Practice
Concepts should make templates easier to use and write. Roger Orr gives a practical example to show this. by Roger Orr

Afterwood
Magazines sometimes use the back page for adverts or summaries. Chris Oldwood has decided to provide us with his afterwords, or ‘afterwood’. by Chris Oldwood

Building And Packaging C++ Modules In Vs2015--Conan's blog

Modules in Conan explained:

Building And Packaging C++ Modules In Vs2015

by Conan's blog

From the article:

This post makes a brief introduction to the C++ modules (we wished C++17, but we will have to wait). Modules have already been experimentally available in an early implementation in CLang, and now Microsoft is also providing them in Visual Studio 2015. We will see their syntax and how to build them, as introduced in the Visual Studio Blog, and at the same time, we will show how to create and consumes packages with C++ modules with conan C/C++ package manager.

Implementing Queues for Event-Driven Programs--“No Bugs” Hare

An interesting article:

Implementing Queues for Event-Driven Programs

by “No Bugs” Hare

From the article:

We’ve already discussed things related to sockets; now let’s discuss the stuff which is often needed (in particular, it is of Utmost Importance when implementing Reactors), but which is not that common to be universally available as a part of operating system.

I’m speaking about queues. And not only just about “some” queue, but about queues which have certain properties desirable for our Reactors a.k.a. ad-hoc Finite State Machines a.k.a. Event-Driven Programs.

CppCon 2015 constexpr: Introduction--Scott Schurr

Have you registered for CppCon 2016 in September? Don’t delay – Early Bird registration is open now.

While we wait for this year’s event, we’re featuring videos of some of the 100+ talks from CppCon 2015 for you to enjoy. Here is today’s feature:

constexpr: Introduction

by Scott Schurr

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

I'm excited about constexpr. It's probably my favorite C++11 feature and it's gotten even better with C++14. This talk will introduce constexpr to the uninitiated. We'll start with C++11 and continue into the improvements introduced with C++14. We'll look into useful ways to think about constexpr code. We'll also cover some tips and tricks with writing constexpr code.

FunctionalPlus--Tobias Hermann

Here is a simple but powerful library that can helps us write code better:

FunctionalPlus

by Tobias Hermann

Summary:

helps you write concise and readable C++ code.

Great code should mostly be self-documenting, but while using C++ in reality you can find yourself dealing with low-level stuff like iterators or hand-written loops that distract from the actual essence of your code.

FunctionalPlus is a small header-only library supporting you in reducing code noise and in dealing with only one single level of abstraction at a time. By increasing brevity and maintainability of your code it can improve productivity (and fun!) in the long run. It pursues these goals by providing pure and easy-to-use functions that free you from implementing commonly used flows of control over and over again.

CppCon 2015 Advanced Unit Testing in C & C++--Matt Hargett

Have you registered for CppCon 2016 in September? Don’t delay – Early Bird registration is open now.

While we wait for this year’s event, we’re featuring videos of some of the 100+ talks from CppCon 2015 for you to enjoy. Here is today’s feature:

Advanced Unit Testing in C & C++

by Matt Hargett

(watch on YouTube) (watch on Channel 9)

Summary of the talk:

This session goes in-depth into advanced techniques to isolate and unit test C++ classes, especially those in legacy code that isn't easy to change. This builds on the Pragmatic Unit Testing in C++ talk from last year, with live code examples of safe refactorings, injecting mock objects, and potential pitfalls across different platforms and toolchains.