Fix order of Context::shutdown.

Calls to stop() need to happen before the call to cleanupWorkerThreads
when using only new worker threads. If stop() doesn't happen until
after we try to join the other threads, many services won't know they
are supposed to be shutting down.
Add timed blocking pop for ThreadSafeQueue.

Use a timeout on the condition variable to possibly return from a
blocking pop without having received an event.
Make unit test driver able to run all suites, one suite, or one test.
Add SST test.

Rename TCPSST test classes to make room for SST classes. Add a Mock,
local datagram layer that supports adjusting delay and lossiness. Use
this to write a few simple tests of SST including basic connectivity
and send/receive over lossless/lossy and no delay/high latency
channels.

Currently some of these fail. This seems mostly to do with the
reasonable timeouts imposed to make sure the tests finish in a
reasonable amount of time, although with lossiness sometimes things
seem to stall. Its not clear if the stalling is due to a failure in
the code or just timeouts that are increasing.
Return number of cancelled handlers from IOTimer events.

These values are important sometimes to ensure you only trigger a
single timer callback.
Make SST::Connections use a single timer.

Centralize (re)scheduling of servicing so we only have one outstanding
timer or callback at any time, and a request for one sooner simply
tries to cancel the existing one and schedule a new, earlier one.
Improve build time after SSTImpl.hpp is updated

Reduce the amount of places SSTImpl.hpp is included by using forward
declaractions, only including SSTImpl.hpp (indirectly via odp/SST.hpp
and ohdp/SST.hpp) in cpp files or in headers in plugins where their
impact is limited. Quite a few files still require it to be included
so the build still isn't fast, but it is significantly faster because
many fewer are affected than before (e.g. it is no longer included by
SpaceContext and ObjectHostContext, which are used pretty much
everywhere except in libcore).
Allow more time for lossy SST tests.

Add timeout parameters to waitForEvents methods and use longer
timeouts for lossy tests because we expect them to take longer as they
back off, especially when RTT estimation hasn't taken effect during
connection initialization.
Fix Connection service scheduling.

Fix the Connection service scheduling and document the approach and
reasoning throughout since it's kind of confusing and error prone. Now
servicing should only occur when there is something to do, either a
packet can be sent (one is available and there is congestion window
space) or a timeout needs to be processed. Various other fixes fall
out from this as well: we no longer incorrectly process initial
packets multiple times and therefore don't increase the number of
retransmissions incorrectly, and the number of retransmissions is only
used for timeouts during the connection phase.
Make SST::Streams use a single timer.

Centralize (re)scheduling of servicing so we only have one outstanding
timer or callback at any time, and a request for one sooner simply
tries to cancel the existing one and schedule a new, earlier one.
Change scheduleService calls to clarify between streams and connections.
Fix SST stream servicing.

Fix SST stream servicing to correctly trigger servicing with a
timeout in the case that serviceStream is invoked but no
additional packets are sent, i.e. if there isn't enough space in
the window for the next packet.

When scheduling the timeout, instead of always using 2*RTT from
the current time, compute the correct timeout taking into account
already elapsed time. This doesn't affect correctness, but makes
things faster since its a strictly earlier timeout.

Improve performance by only triggering servicing when it can
actually have an effect, i.e. if the packet was pushed into an
empty queue. Otherwise we're just wasting effort since we would
otherwise just be cancelling the timer.
Fix an SST stream servicing call.

If we possibly generate multiple packets for a write call, we should
check that at least one packet was successfully added before
scheduling the stream for servicing.
Performance improvements in SSTTest.

There were some stupid things, like copying large buffers for through
each callback, and less obvious issues, like seeding buffers with
random data and manually comparing the delivered data to the
source. Fixing these makes it so the test itself isn't dominating the
cost of the test anymore.
Use SST acks from all types of messages for streams.

Split handling of messages, previously only in Stream::receiveData into
Stream::receiveData and Stream::receiveAck. Change all the handle*Packet methods
to take both the channel header and stream header. In each of those methods,
call receiveData using only stream info, then receiveAck, including the acked
channel segment ID provded by the channel header. For pure ACK packets, only
receiveAck is called.

Previously, when using a single method, the parameter offset was overloaded to
mean either the ByteSequenceNumber or channel segment ID, depending on the type
of message (and when it was ByteSequenceNumber, acks using the channel segment
ID were just ignored). Change the name of the parameter in receiveAck to be
channelSegmentID to indicate that the value being used is the channelSegmentID
assigned when the packet was sent on the connection (which, due to retries, can
resulting different channelSegmentIDs for the same packet). The parameter to
receiveData remains offset, which is the BSN.
When using strands, timers are always able to cancel (active) timers.

Fix the return value from IOTimer::cancel when using strands to always
return 1 since the ability to cancel the underlying ASIO timer doesn't
matter since we also track a value to skip the callback which is
guaranteed to work when using strands (as long ast the timer is
actually still active). Add a note to the method's documentation to
clarify the return value's semantics and when it's useful.

Also remove checking of this value in SST. Although it now returns the
right value, there's no point in checking it anymore since it will
always return 1.
Remove unnecessary copies of data and parsing of messages in SST.

Remove one completely unnecessary parsePBJMessage call. Remove another
since it was actually reparsing a message that was already parsed in
some cases. To do this, split the receiveMessage into two parts, one
which parses the raw message buffer and one which actually does the
work. Also make parsePBJMessage support using MemoryReferences and use
those in place of strings, where we were copying the entire message
just to pass it into parsePBJMessage.
Cancel stream keepalives when the stream is closed.

Convert stream keepalives to timers so they can be canceled. When the
stream is closed, immediately stop the keepalive timers so they don't
block up the event loop.
Stop SST connection check alive callbacks when the connection is closing.

Convert SST connection check alive callbacks to timers and cancel the
timer when the connection is going to be cleaned up. This can happen
in a couple of ways, notably through cleanup() calls during normal
operation and close() calls that are invoked explicitly upon shutdown,
so we need to (possibly) cancel the timer in a couple of places.
Pass stop() requests to SST connections and streams.

Instead of calling closeConnections() in stop(), pass the call along
to Connections, which then pass it on to streams, giving them a chance
to cleanly shutdown. Streams are closed with force=false so they
should finish sending and cleanup cleanly. This, combined with
stopping the checkAlive timer, should also allow Connections to then
be cleaned up.