Just Software Solutions

Published Articles and Presentations

Here is a list of articles and other publications written by one of our directors, Anthony Williams. In each case, the title is linked to the online version.

Book

Anthony is the author of C++ Concurrency in Action, published by Manning, which provides a comprehensive tutorial and reference to the multithreading support in C++11.

It's not just the best current treatment of C++11's threading facilities ... it's likely to remain the best for some time to come. Scott Meyers

Early Access to the second edition now available. The second edition adds coverage of the new facilities from C++14, C++17, and the Concurrency TS

Articles

Issue / Publication DatePublicationTitleDescription
April 2016Overload 132 Using enum classes as bitfields This article is a slightly expanded version of my blog entry: Using enum classes as bitfields.
August 2015Overload 128 Numbers in Javascript This article is a slightly expanded version of my blog entry: Numbers in Javascript.
October 2011Overload 105 Picking patterns for parallel programs A description of design patterns for parallel programs, and some guidance on when each is useful.
September 2010DrDobbs.com Concept Checking Without Concepts in C++ One of the important features of the now-defunct C++0x Concepts proposal was the ability to overload functions based on whether or not their arguments met certain concepts. This article describes a way to allow that for concepts based on the presence of particular member functions.
May 2010DrDobbs.com Enforcing Correct Mutex Usage with Synchronized Values This article expands on the SynchronizedValue<T> template I mentioned in my presentation on Concurrency in the Real World at ACCU 2010, and deals with the problem of ensuring that the mutex associated with some data is locked whenever the data is accessed.
April 2010DrDobbs.com Simple Concurrency with Dataflow Variables in C++ Dataflow variables are write-once read-many variables with in-built synchronization. In this article I explain how they can be used to write scalable code with no race conditions, and how to implement them in C++.
October 2009Overload 93 Multi-threading in C++0x An overview of the new multithreading facilities in C++0x.
September 2009DevX.com Avoiding the Perils of C++0x Data Races Race conditions are one of the biggest causes of problems in multithreaded code. This article takes a brief look at some of the ways in which race conditions can occur. There is also sample code that demonstrates the perils of data races by showing how even simple code with a data race can lead to corrupt data.
May 2009DevX.com Introduction to Variadic Templates in C++0x This article introduces the new variadic template facility from C++0x, which allows you to write templates that take a variable number of template arguments.
November 2008Dr. Dobb's Journal What's New in Boost Threads? This article gives an overview of the new features added to the Boost thread library in the recent releases.
September 2008Codeguru.com Deadlock: The problem and a solution This is an excerpt from Anthony's book C++ Concurrency in Action, and describes the problem of deadlock and ways to avoid it.
August 2008DevX.com Simpler Multithreading in C++0x Part of DevX.com's Special Report on C++0x, this article provides a whistle-stop tour of the new C++0x multithreading support.
August 2008Overload 86 Exceptions make for Elegant Code This article is a slightly expanded version of my blog entry: Exceptions make for Elegant Code.
April 2008Dr. Dobb's Journal Optimizing Math-intensive Applications with Fixed Point Arithmetic This article describes the fixed-point techniques used to vastly improve the performance of an application using sines, cosines and exponentials without hardware floating point support.
The source code referenced in the article can be downloaded from here. It is released under the Boost Software License.
April 2007Overload 78 Implementing Synchronization Primitives for Boost on Windows Platforms This article describes the techniques involved in writing a new mutex implementation for Windows.
June 2006CVu 18.3 Building on a Legacy This article discusses ways of handling legacy code, and how to work so that maintenance gets easier rather than harder.
June 2006Overload 73 Implementing drop-down menus in pure CSS (no JavaScript) This article describes the details behind implementing drop-down menus with CSS in a cross-browser fashion.
May 2006Dr. Dobb's Journal Message Handling Without Dependencies This article describes a type-safe technique for passing messages around an application in C++, without requiring extensive coupling between the producer and consumer
April 2004CVu 16.2 Writing Maintainable Code A brief summary of techniques to help you write maintainable code.
November 2003C/C++ Users Journal Strong Exception-Safe Storage This article describes the use of a double-buffer technique to provide the Strong Exception Safety Guarantee without the use of dynamic memory, even when the underlying data only provides the Basic Exception Safety Guarantee.
April 2003Overload 54 EXPR_TYPE — An Implementation of typeof Using Current Standard C++ (PDF) typeof is a much-sought-after facility that is lacking from current C++; it is the ability to declare a variable to have the same type as the result of a given expression, or make a function have the same type as an expression. The general idea is that typeof(some-expression) would be usable anywhere a type name could normally be used. This article describes a way of providing this ability within the realms of current C++. There is code to accompany this article.
October 2002Overload 51 Pairing Off Iterators (PDF) This article describes the implementation of an iterator adaptor that converts a pair of ranges into a range of pairs, so that two containers can be sorted by a key held in only one of them, for example. The code is available for download
October 2001Overload 45 Introduction to C++ Templates (PDF) This is a brief introduction to C++ templates - how they work, how to use them, and how to write your own.
August 2001Overload 44 Flexible Functors and Binders (PDF) This article describes a set of binders to assist writing programs using the Functional Programming style, and a set of adaptors for other functors, such as pointers-to-functions and pointers-to-member-functions, to enable them to be integrated seamlessly. The code to accompany the article can be downloaded.
April 2001Overload 42 A Generic Non-Intrusive Smart Pointer Implementation (PDF) This article describes the implementation of a smart pointer that can be freely converted to and from a raw pointer, or other types of smart pointer, without losing its reference count. It also permits the use of arrays, and the use of dynamic_cast. The code to accompany the article can be downloaded. There is an erratum for this article.

Presentations

DateLocationTitleDescription
20th September 2016cppcon 2016 "The continuing future of C++ concurrency" An overview at the additions to the Standard C++ concurrency libraries proposed for the C++ concurrency TS and C++17, including: continuations, executors, and parallel algorithms, as well as std::shared_mutex from C++14. The slides are available as a PDF.
9th June 2016NDC Oslo 2016 "Safety: off. How not to shoot yourself in the foot with C++ atomics" If you're writing multithreaded code, it is tempting to use atomics to optimize the inter-thread synchronization and access to shared state. However, this is not always easy, and can all too often lead to code that appears to work but is subtly broken. I showed tools and techniques for using atomics safely in C++, as well as discussing scalability and lock-freedom. The slides are available as a PDF.
8th June 2016NDC Oslo 2016 "The continuing future of C++ concurrency" An overview at the additions to the Standard C++ concurrency libraries proposed for the C++ concurrency TS and C++17, including: continuations, executors, and parallel algorithms, as well as std::shared_mutex from C++14. The slides are available as a PDF.
23rd April 2016ACCU 2016 "Concurrent Thinking" One of the most difficult issues around designing software with multiple threads of execution is synchronizing data. Whether you use actors, active objects, futures and continuations or mutable shared state, every non-trivial system with multiple threads needs to transfer data between them. This means thinking about which data needs to be processed by which thread, and ensuring that the right data gets to the right threads in the right order. It also means thinking about API design to avoid race conditions. In this presentation I described techniques we can use when doing this "thinking", as well as the tools we have available to help us describe our requirements and enforce them in code. All examples use C++, but the thought processes are widely applicable. The slides are available as a PDF.
3rd September 2015Agile on the Beach 2015 "Test Driving User Interfaces" User interfaces are generally considered one of the harder things to develop with Test-Driven Development (TDD). So much so that a common recommendation is to make your user interface code as thin as possible, and test the layer behind the UI rather than the UI itself.
In this presentation I showed that it is possible to test the UI layer with the techniques we already use for backend code, and that this doesn’t have to be painful.
If you truly can get your thin UI layer so simple that it couldn’t possibly break, it makes sense not to test it. However, if your UI layer is more than just a few simple controls with minimal behaviour then doing this properly requires that the thin UI layer actually ends up quite complex, as it has to pass through all the events generated by the UI, as well as provide facilities for any UI changes made through the UI API. At this point, testing behind the UI leaves quite a lot of complex code untested, and thus a prime breeding ground for bugs.
What is needed therefore is a way of working that allows us to bring our TDD experience to the development of UI code in a pain free fashion. This session showed that this isn’t just a pipe dream. The slides are available as a PDF.
25th April 2015ACCU 2015 "Safety: off. How not to shoot yourself in the foot with C++ atomics" If you're writing multithreaded code, it is tempting to use atomics to optimize the inter-thread synchronization and access to shared state. However, this is not always easy, and can all too often lead to code that appears to work but is subtly broken. I showed tools and techniques for using atomics safely in C++, as well as discussing scalability and lock-freedom. The slides are available as a PDF.
12th April 2014ACCU 2014 "The continuing future of C++ concurrency" An overview at the additions to the Standard C++ concurrency libraries proposed for the C++ concurrency TS and C++17, including: continuations, executors, and parallel algorithms, as well as std::shared_mutex from C++14. The slides are available as a PDF.
11th April 2013ACCU 2013 "C++11 features and real-world code" C++11 has many nifty features, but how do they actually impact developers at the code face? Which C++11 features offer the best bang for the buck? In this session I looked at a selection of C++11 language and library features that I've found of real practical benefit in application and library code, with examples of equivalent C++03 code. The features covered included the concurrency support (of course), lambdas, and “auto”, amongst a variety of others.
27th April 2012ACCU 2012 "C++11 concurrency tutorial" In this tutorial-style session, I introduced the C++11 concurrency library in depth, with live practical examples. This was for both those who've never used concurrency before, but want to start, and those who have used other concurrency libraries but want to learn how to take advantage of the C++11 library. I covered the details of the library, along with practical guidelines about how best to avoid deadlock, race conditions and other concurrency problems. The slides are available as a PDF.
26th April 2012ACCU 2012 "Dataflow, actors, and high level structures in concurrent applications" In this session I gave an overview of various high level approaches to concurrency, including dataflow architectures and actor libraries. Examples were be drawn from several languages and platforms, including C++ and Groovy. The slides are available as a PDF.
16th April 2011ACCU 2011 "Choosing patterns for your parallel program" There are many ways of structuring parallel programs, and a good many buzzwords surrounding them. In this talk I looked at several of the standard patterns that you can use to take advantage of concurrency in your application alongside the circumstances under which each might be appropriate. I also talked about the various patterns for communicating between threads, how those relate to the structural patterns, and the trade-offs involved with the choices. The slides are available as a PDF.
14th April 2010ACCU 2010 "Concurrency in the Real World" This talk covered the common problems people have with multithreaded and concurrent code, and some solutions to those problems, with examples in C++. It also covered the potential benefits of using concurrency, along with some things to watch out for in pursuit of those benefits. The slides are available as a PDF.
23rd April 2009ACCU 2009 "Designing Multithreaded Applications with C++0x" This talk covered the issues involved in designing multithreaded applications, along with examples of how to approach them from a C++0x perspective. This included an overview of the new C++0x thread library, examples of how features such as futures can affect the programming model, and issues to think about when reviewing and testing multithreaded code. The slides are available as a PDF, along with a ZIP file with the sample code for the Concurrent Queue and Numerical Integration demonstrations that I did during the presentation using our just::thread implementation of the C++0x thread library.
3rd April 2008ACCU 2008 The Future of Concurrency in C++ With the next version of the C++ Standard (C++0x), concurrency support is being added to C++. This means a new memory model with support for multiple threads of execution and atomic operations, and a new set of library classes and functions for managing threads and synchronizing data. There are also further library enhancements planned for the next technical report (TR2). This talk will provide an overview of the new facilities, including an introduction to the new memory model, and an in-depth look at how to use the new library. Looking forward to TR2, this talk covered the proposed library extensions, and how facilities like futures will affect the programming model. The slides are available as a PDF.
3rd April 2002ACCU Spring Conference 2002 Function Composition and Return Type Deduction (PDF) This presentation describes my function composition library, which is available for download. This library provides a facility for creating composite functions from basic ones at the point of use, and can be used to create a simple lambda expression facility.

C++ Standards Committee Papers

Issue / Publication DatePublicationTitleDescription
March 2017C++ Standards Committee Mailing P0623R0: Final C++17 Parallel Algorithms Fixes Apply final changes to the parallel algorithms for C++17.
March 2017C++ Standards Committee Mailing P0574R1: Algorithm Complexity Constraints and Parallel Overloads A revision of P0547R0 based on feedback from SG1 and LWG
March 2017C++ Standards Committee Mailing P0290R2: apply() for synchronized_value<T> A revision of P0290R1 to allow coexistence with apply for std::tuple
February 2017C++ Standards Committee Mailing P0574R0: Algorithm Complexity Constraints and Parallel Overloads Modifications to the C++17 draft to better specify the complexity constraints of parallel algorithms to allow efficient implementations.
October 2016C++ Standards Committee Mailing P0290R1: apply() for synchronized_value<T> Revision of P0290R0 based on feedback from SG1
March 2016C++ Standards Committee Mailing P0290R0: apply() for synchronized_value<T> A revision of N4032; all operations on the value wrapped in a synchronized_value<T> are now down through a separate apply function.
November 2015C++ Standards Committee Mailing P0158R0: Couroutines belong in a TS BSI position paper advocating coroutines being in a TS rather than moved straight to the standard.
April 2015C++ Standards Committee Mailing P0120R0: constexpr unions and common initial sequences A proposal to allow accessing common initial sequences of structs in constexpr unions, the same as allowed for non-constexpr unions, in order to allow more space-efficient variant implementations.
April 2015C++ Standards Committee Mailing P0110R0: Implementing the strong guarantee for variant<> assignment Description of the difficulties in implementing the strong guarantee for std::variant, with techniques on how to do it, and the requirements on the types for the various options.
May 2014C++ Standards Committee Mailing N4033: synchronized_value<T> for associating a mutex with a value synchronized_value<T> wraps a mutex and a value so you cannot access the value without locking the mutex
May 2014C++ Standards Committee Mailing N4032: Comments on continuations and executors My comments on the executors proposal for the Concurrency TS
November 2010C++ Standards Committee Mailing N3197: Lockable requirements for C++0x A revision of N3130
August 2010C++ Standards Committee Mailing N3131: Compile-time rational arithmetic and overflow Document the handling of overflow in std::ratio operations
August 2010C++ Standards Committee Mailing N3130: Lockable requirements for C++0x This paper revises the wording for the C++0x draft for mutexes to gather together common requirements
February 2010C++ Standards Committee Mailing N3038: Managing the lifetime of thread_local variables with contexts (Revision 2) A revision of N2959, adding support for nested contexts
September 2009C++ Standards Committee Mailing N2959: Managing the lifetime of thread_local variables with contexts (Revision 1) This is a revision of my earlier paper, N2907 which expands my proposal for a thread_local_context class, along with full proposed wording. I think this provides a workable solution to the general problem of ensuring that destructors for thread_local variables are run at particular points in the execution of a program as discussed in N2880.
September 2009C++ Standards Committee Mailing N2967: Issues on Futures This paper that I co-authored with Detlef Vollmann provides a complete rewording for the "Futures" section of the standard (30.6). It folds the proposed changes from N2888 in with changes requested by the LWG at July's meeting (including the addition of a new future type — atomic_future which serializes all operations), and editorial comments on the earlier wording. It doesn't resolve everything — there is still some discussion over whether unique_future::get() should return a value or a reference, for example — but it provides a sound basis for further discussion.
June 2009C++ Standards Committee Mailing N2907: Managing the lifetime of thread_local variables with contexts This paper introduces the idea of a thread_local_context which manages the lifetime of variables declared thread_local. In particular, this concept is introduced to manage the interaction of thread_local variables with detached threads and asynchronous function calls.
June 2009C++ Standards Committee Mailing N2888: Moving Futures - Proposed Wording for UK comments 335, 336, 337 and 338 This paper provides rationale and proposed wording for the UK comments on the C++ working draft requesting move semantics for std::unique_future and std::shared_future.
July 2008C++ Standards Committee Mailing N2709: Packaging Tasks for Asynchronous Execution This paper proposes a revised version of packaged_task following its removal from N2671.
June 2008C++ Standards Committee Post-Sophia Antipolis Mailing N2671: An Asynchronous Future Value Proposed Wording Jointly authored with Deltef Vollmann and Howard Hinnant. An updated version of N2627 with proposed wording. packaged_task has been removed for a later proposal.
May 2008C++ Standards Committee Pre-Sophia Antipolis Mailing N2627: An Asynchronous Future Value (Revised) Jointly authored with Deltef Vollmann and Howard Hinnant. An updated version of N2561.
March 2008C++ Standards Committee Post-Bellevue Mailing N2561: An Asynchronous Future Value Jointly authored with Deltef Vollmann and Howard Hinnant. Futures, promises and packaged tasks for multi-threaded programming. See Futures and Tasks in C++0x for a summary.
September 2007C++ Standards Committee Pre-Kona Mailing Names, Linkage and Templates (Rev 2) (PDF) This paper is an update to the earlier proposals for making local types usable with templates (N1945 and N2187), with revised wording.
June 2007C++ Standards Committee Pre-Toronto Mailing Multi-threading library for Standard C++ This paper (jointly authored with Howard Hinnant, Beman Dawes, Lawrence Crowl and Jeff Garland) proposes a set of classes for a basic thread library for C++, including thread launching, mutexes and condition variables.
May 2007C++ Standards Committee Post-Oxford Mailing Thread Pools and Futures This paper proposes new classes to the C++ Standard Library for thread pools and futures, to build on top of the new threading facilities.
March 2007C++ Standards Committee Pre-Oxford Mailing Names, Linkage and Templates (rev 1) (PDF) This paper is an update to the earlier proposal for making local types usable with templates (N1945), with revised examples, motiviation and wording.
November 2006C++ Standards Committee Post-Portland Mailing Thoughts on a Thread Library for C++ This paper outlines thoughts on various aspects of a thread library for C++, including one-time initialization, and general thread synchronization.
February 2006C++ Standards Committee Pre-Berlin Mailing Names, Linkage and Templates (PDF) This paper proposes that the C++ Standard is changed, so that unnamed and local types have linkage, in order to simplify the language and make these types usable with templates.
March 2003C++ Standards Committee Pre-Oxford Mailing Making Local Classes more Useful (PDF) This paper proposes a couple of small changes to the C++ Standard: to allow local classes to work with templates, and to allow local classes to declare friend functions.

Design and Content Copyright © 2005-2017 Just Software Solutions Ltd. All rights reserved.