Add delegate and counter abstractions.

Delegate is a simple crude primitive to build event loops on top. Meant for uses where a thread
wants to do some work inline but if it cannot then offload it to a single threaded delegate. That
in turn is used to build a counter which is manipulated using atomics and when it runs out, the
single threaded delegate execution does FIFO/fair allocation. The delegate itself does each
allocation using atomics and that can be batched up to do combined allocation for multiple waiting
threads but that optimization is for some other day. The current code is far simpler.

Also fixed a but in dlist code which wasn't setting up back pointers on insert. Added some more
general asserts and checks.
Create a common base event that uses an on stack waiter structure to do the
actual waiting. Useful for cases where the dedicated waiter for the thread
cannot be used.
Add 32 bit pointer based singly linked list.

the list also has per node locks and iterators that utilize them. Until there are 3-bit
rwlocks, the iteration parallelism is really constrained. Also added a more general abstraction
for mapping full pointers to shorter values. Only 32 bit version written up so far but others
should be trivially possible to add.
Merge pull request #19 from fcbotelho/delegate

Delegation for event loops and counters based on them