Implement a simple resource lock (threading)

In this initial implementation Locks are no-ops on platforms other than
Windows.
Win: Use SetConsoleCtrlHandler for SIGINT/SIGTERM
Define a type for signal handlers
Merge branch 'master' into win-ctrl-c