Masks

2020-04-26

 

DISCLAIMER: The information given in this post is a best effort attempt at making my family safe and spreading useful information, i am just an engineer.

Let's talk about masks.
Lets talk about you and me,
Let's talk about all the good and bad things that may be,
Let's talks about masks.

Ok, that was a bit tortured, but masks are important, even for the general population. You may have heard that makes have no significant effect in preventing, virus spread and that is not entirely wrong.

Many well founded scientific opinions can be found, one that I kept coming across was COMMENTARY: Masks-for-all for COVID-19 not based on sound data, which asserts, that

In sum, given the paucity of information about their performance as source control in real-world settings, along with the extremely low efficiency of cloth masks as filters and their poor fit, there is no evidence to support their use by the public or healthcare workers to control the emission of particles from the wearer.

Which is a reasonable assumptions about cloth masks in a health care setting. But this assertion is extended to the use of masks in the general populace with the added caveat

Leaving aside the fact that they are ineffective, telling the public to wear cloth or surgical masks could be interpreted by some to mean that people are safe to stop isolating at home.

At least in Germany, the mask carrying laws still emphasize social distancing and go only in effect in situations where the 1.5m distance rule can not easily be applied, such as in public transportation and during shopping.

read more

Immutable Containers and Thread Safety

2020-03-07

 

I have been using immutable.js recently and in the context of JavaScript it makes a lot of sense. The problem I am trying to solve with immutable.js is the aliasing problem. That is, I get a list of widgets from somewhere and I need to alter the list before I can display it. Doing this in-place is not a good idea, because this may break some other code that holds onto the list.

I like this programming idiom so much that I am seriously considering mplementing it in C++. While I am tinkering with my C++ experimental code and my research I keep coming across the assertion that immutable objects are thread safe. The original presentation or this rather nice article mention it as if it was an immutable truth.

But they are just wrong. It is true that with the right use of atomics you can create immutable containers that will not have memory races or crash, but that does not make them functionally correct.

Take a well known example from multi-threading programming, the humble bank account. In our case we will represent the bank account as an immutable ledger of all transactions that occurred. All you can do to the ledger is add transactions, so the naive implementation would be as follows:

class Account
{
public:
    void append(const Transaction& transaction)
    {
        ledger = ledger.push_back(transaction);
    }

private:
    i7e::imutable_list<Transaction> ledger;
};

read more

C++ Signals

2020-02-15

 

While working on one of my current hobby projects I needed to broadcast a state change to more than just one observer. I was quick to add my rather trusted EventEmitter. But I did hesitate, because something about the EventEmitter always bothered me.

The problem with EventEmitter is that, although EventEmitter is type safe, the type safety can only be asserted during runtime. A bit like JavaScript, where it comes from, assigning wrong typed handlers will throw an exception when the caller is actually called.

enum 
{
    FOO_EVENT
};

EventEmitter emitter;
emitter.on(FOO_EVENT, [] (int c) {
    // do something
});

long change_value = 42;
emitter.emit(FOO_EVENT, change_value); // exception

This was always annoying, since there are so many different types that are effectively the same, but the compiler really things are different. For example, the types size_t, int and long can be the same type, and yet the compiler thinks they are not.

read more