Reimplemented cEvent using C++11 primitives.

This needs a bit more testing; I've only verified that it works on Windows.

@archshift can you try if it fixes the OS X problems you reported?