This is in preparation for a WrapCurrentThread method,
or AutoThread constructor, taking a socket
server as argument, to eliminate the need for the
MessageQueue::set_socketserver method and its lock.
No intended change in behaviour; the ThreadManager constructor
records the calling thread id, and autowrap is still restricted to
that thread. Behavior when NO_MAIN_THREAD_WRAPPING is defined is
also unchanged.
Also makes the ThreadManager a singleton, with private constructor
and destructor. And marks its destructor as RTC_NOTREACHED, since
by the documentation for RTC_DEFINE_STATIC_LOCAL, the intention is to
leak the object and never destruct it.
BUG=webrtc:7501
Review-Url: https://codereview.webrtc.org/2833993003
Cr-Commit-Position: refs/heads/master@{#17879}
Due to quirks of the Cocoa runtime several platform-specific fixes were
in place. See the deleted files maccocoathreadhelper and
scoped_autorelease_pool for examples. There is no way to do a stack-based
RAII autoreleasepool that is compatible with ARC, and autoreleasepool
blocks can't be used with c++. The solution was to separate out the
implementation of some methods in thread.h to an ObjC++ file for Darwin
platforms, allowing us to get rid of the helper classes and enable ARC
everywhere.
BUG=webrtc:6412
Review-Url: https://codereview.webrtc.org/2784483002
Cr-Commit-Position: refs/heads/master@{#17436}