diff options
author | Monty Brandenberg <monty@lindenlab.com> | 2012-06-26 12:28:58 -0400 |
---|---|---|
committer | Monty Brandenberg <monty@lindenlab.com> | 2012-06-26 12:28:58 -0400 |
commit | e8b0088d1a0c02bfa1f9768dc91fc3df4322adae (patch) | |
tree | 336f5484cf97d0538599250c4c405ac28866234c /indra/llcorehttp/_thread.h | |
parent | e172ec84fa217aae8d1e51c1e0673322c30891fe (diff) |
SH-3184/SH-3221 More work on cleanup with better unit test work and more aggressive shutdown of a thread.
Some additional work let me enable a memory check for the clean shutdown case and
generally do a better job on other interfaces. Request queue waiters now awake
on shutdown and don't sleep once the queue is turned off. Much better semantically
for how this will be used.
Diffstat (limited to 'indra/llcorehttp/_thread.h')
-rw-r--r-- | indra/llcorehttp/_thread.h | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/indra/llcorehttp/_thread.h b/indra/llcorehttp/_thread.h index 4cf35055e9..e058d660e5 100644 --- a/indra/llcorehttp/_thread.h +++ b/indra/llcorehttp/_thread.h @@ -52,12 +52,10 @@ private: } void run() - { // THREAD CONTEXT + { // THREAD CONTEXT - // The implicit reference to this object is taken for the at_exit - // function so that the HttpThread instance doesn't disappear out - // from underneath it. Other holders of the object may want to - // take a reference as well. + // Take out additional reference for the at_exit handler + addRef(); boost::this_thread::at_thread_exit(boost::bind(&HttpThread::at_exit, this)); // run the thread function @@ -65,13 +63,17 @@ private: } // THREAD CONTEXT +protected: + virtual ~HttpThread() + { + delete mThread; + } + public: /// Constructs a thread object for concurrent execution but does - /// not start running. Unlike other classes that mixin RefCounted, - /// this does take out a reference but it is used internally for - /// final cleanup during at_exit processing. Callers needing to - /// keep a reference must increment it themselves. - /// + /// not start running. Caller receives on refcount on the thread + /// instance. If the thread is started, another will be taken + /// out for the exit handler. explicit HttpThread(boost::function<void (HttpThread *)> threadFunc) : RefCounted(true), // implicit reference mThreadFunc(threadFunc) @@ -83,11 +85,6 @@ public: mThread = new boost::thread(f); } - virtual ~HttpThread() - { - delete mThread; - } - inline void join() { mThread->join(); |