These are a few things I learned today .
In one part of our code we use
std::async to launch multiple worker threads that query remote devices and gather results. Before, this functionality would simply return all the results from the query, however we needed to implement a
size parameter so that total number of results does not exceed that number.
To do this we use an
std::atomic_uint64_t to act as a counter synced across the multiple threads. We pass that and a function object into
std::async. However, for reasons explained here,
std::async makes copies of all its arguments, but
std::atomic_uint64_t is not copy-constructible (nor it would make no sense to pass in a copy). Therefore we wrap the counter with
std::ref which generates a
std::reference_wrapper<T> object. This object is copy-constructible but allows you to treat it as a reference of the wrapped type.
Ignore whitespace in Github diff views
Our team consists of several developers on multiple operating systems. We cannot always agree on the tabs vs spaces argument, which can sometimes make it difficut to see past the noise when viewing diffs in pull-requests.
Github to the rescue! When viewing diffs in Github you can have the view ignore whitespaces-differences by adding
?w=1 to the URL.