2010-10-14 08:30:07 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-06-13 14:17:57 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
Better fix for ThreadPool/ORequestThread life cycle
This is a follow up to d015384e1d98fe77fd59339044f58efb1ab9fb25 "Fixed
ThreadPool (and dependent ORequestThread) life cycle" that still had some
problems:
* First, if Bridge::terminate was first entered from the reader or writer
thread, it would not join on that thread, so that thread could still be running
during exit.
That has been addressed by giving Bridge::dispose new semantics: It waits until
both Bridge::terminate has completed (even if that was called from a different
thread) and all spawned threads (reader, writer, ORequestThread workers) have
been joined. (This implies that Bridge::dispose must not be called from such a
thread, to avoid deadlock.)
* Second, if Bridge::terminate was first entered from an ORequestThread, the
call to uno_threadpool_dispose(0) to join on all such worker threads could
deadlock.
That has been addressed by making the last call to uno_threadpool_destroy wait
to join on all worker threads, and by calling uno_threadpool_destroy only from
the final Bridge::terminate (from Bridge::dispose), to avoid deadlock. (The
special semantics of uno_threadpool_dispose(0) are no longer needed and have
been removed, as they conflicted with the fix for the third problem below.)
* Third, once uno_threadpool_destroy had called uno_threadpool_dispose(0), the
ThreadAdmin singleton had been disposed, so no new remote bridges could
successfully be created afterwards.
That has been addressed by making ThreadAdmin a member of ThreadPool, and making
(only) those uno_ThreadPool handles with overlapping life spans share one
ThreadPool instance (which thus is no longer a singleton, either).
Additionally, ORequestThread has been made more robust (in the style of
salhelper::Thread) to avoid races.
Change-Id: I2cbd1b3f9aecc1bf4649e482d2c22b33b471788f
2012-05-23 09:42:37 +02:00
|
|
|
|
|
|
|
#ifndef INCLUDED_CPPU_SOURCE_THREADPOOL_THREADPOOL_HXX
|
|
|
|
#define INCLUDED_CPPU_SOURCE_THREADPOOL_THREADPOOL_HXX
|
|
|
|
|
2016-08-31 16:23:09 +02:00
|
|
|
#include <vector>
|
2014-12-27 21:01:22 +00:00
|
|
|
#include <unordered_map>
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2015-08-18 08:15:29 +02:00
|
|
|
#include <osl/conditn.hxx>
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
#include <rtl/byteseq.hxx>
|
Better fix for ThreadPool/ORequestThread life cycle
This is a follow up to d015384e1d98fe77fd59339044f58efb1ab9fb25 "Fixed
ThreadPool (and dependent ORequestThread) life cycle" that still had some
problems:
* First, if Bridge::terminate was first entered from the reader or writer
thread, it would not join on that thread, so that thread could still be running
during exit.
That has been addressed by giving Bridge::dispose new semantics: It waits until
both Bridge::terminate has completed (even if that was called from a different
thread) and all spawned threads (reader, writer, ORequestThread workers) have
been joined. (This implies that Bridge::dispose must not be called from such a
thread, to avoid deadlock.)
* Second, if Bridge::terminate was first entered from an ORequestThread, the
call to uno_threadpool_dispose(0) to join on all such worker threads could
deadlock.
That has been addressed by making the last call to uno_threadpool_destroy wait
to join on all worker threads, and by calling uno_threadpool_destroy only from
the final Bridge::terminate (from Bridge::dispose), to avoid deadlock. (The
special semantics of uno_threadpool_dispose(0) are no longer needed and have
been removed, as they conflicted with the fix for the third problem below.)
* Third, once uno_threadpool_destroy had called uno_threadpool_dispose(0), the
ThreadAdmin singleton had been disposed, so no new remote bridges could
successfully be created afterwards.
That has been addressed by making ThreadAdmin a member of ThreadPool, and making
(only) those uno_ThreadPool handles with overlapping life spans share one
ThreadPool instance (which thus is no longer a singleton, either).
Additionally, ORequestThread has been made more robust (in the style of
salhelper::Thread) to avoid races.
Change-Id: I2cbd1b3f9aecc1bf4649e482d2c22b33b471788f
2012-05-23 09:42:37 +02:00
|
|
|
#include <rtl/ref.hxx>
|
|
|
|
#include <salhelper/simplereferenceobject.hxx>
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
#include "jobqueue.hxx"
|
|
|
|
|
|
|
|
|
|
|
|
namespace cppu_threadpool {
|
|
|
|
class ORequestThread;
|
|
|
|
|
|
|
|
struct EqualThreadId
|
|
|
|
{
|
2014-01-27 10:44:30 +01:00
|
|
|
bool operator () ( const ::rtl::ByteSequence &a , const ::rtl::ByteSequence &b ) const
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
|
|
|
return a == b;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct HashThreadId
|
|
|
|
{
|
|
|
|
sal_Int32 operator () ( const ::rtl::ByteSequence &a ) const
|
|
|
|
{
|
|
|
|
if( a.getLength() >= 4 )
|
|
|
|
{
|
2015-01-17 18:18:10 +01:00
|
|
|
return *reinterpret_cast<sal_Int32 const *>(a.getConstArray());
|
2000-09-18 14:29:57 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2014-12-27 21:01:22 +00:00
|
|
|
typedef std::unordered_map
|
2000-09-18 14:29:57 +00:00
|
|
|
<
|
2014-05-19 00:36:42 +02:00
|
|
|
::rtl::ByteSequence, // ThreadID
|
2017-02-15 23:55:18 +02:00
|
|
|
std::pair < JobQueue * , JobQueue * >,
|
2000-09-18 14:29:57 +00:00
|
|
|
HashThreadId,
|
|
|
|
EqualThreadId
|
|
|
|
> ThreadIdHashMap;
|
|
|
|
|
|
|
|
struct WaitingThread
|
|
|
|
{
|
2015-08-18 08:15:29 +02:00
|
|
|
osl::Condition condition;
|
Better fix for ThreadPool/ORequestThread life cycle
This is a follow up to d015384e1d98fe77fd59339044f58efb1ab9fb25 "Fixed
ThreadPool (and dependent ORequestThread) life cycle" that still had some
problems:
* First, if Bridge::terminate was first entered from the reader or writer
thread, it would not join on that thread, so that thread could still be running
during exit.
That has been addressed by giving Bridge::dispose new semantics: It waits until
both Bridge::terminate has completed (even if that was called from a different
thread) and all spawned threads (reader, writer, ORequestThread workers) have
been joined. (This implies that Bridge::dispose must not be called from such a
thread, to avoid deadlock.)
* Second, if Bridge::terminate was first entered from an ORequestThread, the
call to uno_threadpool_dispose(0) to join on all such worker threads could
deadlock.
That has been addressed by making the last call to uno_threadpool_destroy wait
to join on all worker threads, and by calling uno_threadpool_destroy only from
the final Bridge::terminate (from Bridge::dispose), to avoid deadlock. (The
special semantics of uno_threadpool_dispose(0) are no longer needed and have
been removed, as they conflicted with the fix for the third problem below.)
* Third, once uno_threadpool_destroy had called uno_threadpool_dispose(0), the
ThreadAdmin singleton had been disposed, so no new remote bridges could
successfully be created afterwards.
That has been addressed by making ThreadAdmin a member of ThreadPool, and making
(only) those uno_ThreadPool handles with overlapping life spans share one
ThreadPool instance (which thus is no longer a singleton, either).
Additionally, ORequestThread has been made more robust (in the style of
salhelper::Thread) to avoid races.
Change-Id: I2cbd1b3f9aecc1bf4649e482d2c22b33b471788f
2012-05-23 09:42:37 +02:00
|
|
|
rtl::Reference< ORequestThread > thread;
|
2015-08-18 08:15:29 +02:00
|
|
|
|
|
|
|
explicit WaitingThread(
|
|
|
|
rtl::Reference<ORequestThread> const & theThread);
|
2000-09-18 14:29:57 +00:00
|
|
|
};
|
|
|
|
|
2017-11-17 20:19:56 +01:00
|
|
|
typedef std::deque< struct ::cppu_threadpool::WaitingThread * > WaitingThreadDeque;
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2010-10-11 10:41:50 +01:00
|
|
|
class DisposedCallerAdmin;
|
2015-09-14 09:21:33 +01:00
|
|
|
typedef std::shared_ptr<DisposedCallerAdmin> DisposedCallerAdminHolder;
|
2010-10-11 10:41:50 +01:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
class DisposedCallerAdmin
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
~DisposedCallerAdmin();
|
|
|
|
|
2017-12-22 14:23:16 +02:00
|
|
|
static DisposedCallerAdminHolder const & getInstance();
|
2006-04-26 19:50:44 +00:00
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
void dispose( sal_Int64 nDisposeId );
|
2012-05-16 22:09:21 +02:00
|
|
|
void destroy( sal_Int64 nDisposeId );
|
2014-02-15 17:39:35 +01:00
|
|
|
bool isDisposed( sal_Int64 nDisposeId );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
::osl::Mutex m_mutex;
|
2017-11-17 20:19:56 +01:00
|
|
|
std::vector< sal_Int64 > m_vector;
|
2000-09-18 14:29:57 +00:00
|
|
|
};
|
|
|
|
|
Better fix for ThreadPool/ORequestThread life cycle
This is a follow up to d015384e1d98fe77fd59339044f58efb1ab9fb25 "Fixed
ThreadPool (and dependent ORequestThread) life cycle" that still had some
problems:
* First, if Bridge::terminate was first entered from the reader or writer
thread, it would not join on that thread, so that thread could still be running
during exit.
That has been addressed by giving Bridge::dispose new semantics: It waits until
both Bridge::terminate has completed (even if that was called from a different
thread) and all spawned threads (reader, writer, ORequestThread workers) have
been joined. (This implies that Bridge::dispose must not be called from such a
thread, to avoid deadlock.)
* Second, if Bridge::terminate was first entered from an ORequestThread, the
call to uno_threadpool_dispose(0) to join on all such worker threads could
deadlock.
That has been addressed by making the last call to uno_threadpool_destroy wait
to join on all worker threads, and by calling uno_threadpool_destroy only from
the final Bridge::terminate (from Bridge::dispose), to avoid deadlock. (The
special semantics of uno_threadpool_dispose(0) are no longer needed and have
been removed, as they conflicted with the fix for the third problem below.)
* Third, once uno_threadpool_destroy had called uno_threadpool_dispose(0), the
ThreadAdmin singleton had been disposed, so no new remote bridges could
successfully be created afterwards.
That has been addressed by making ThreadAdmin a member of ThreadPool, and making
(only) those uno_ThreadPool handles with overlapping life spans share one
ThreadPool instance (which thus is no longer a singleton, either).
Additionally, ORequestThread has been made more robust (in the style of
salhelper::Thread) to avoid races.
Change-Id: I2cbd1b3f9aecc1bf4649e482d2c22b33b471788f
2012-05-23 09:42:37 +02:00
|
|
|
class ThreadAdmin
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ThreadAdmin();
|
|
|
|
~ThreadAdmin ();
|
|
|
|
|
2014-11-14 16:05:37 +01:00
|
|
|
bool add( rtl::Reference< ORequestThread > const & );
|
Better fix for ThreadPool/ORequestThread life cycle
This is a follow up to d015384e1d98fe77fd59339044f58efb1ab9fb25 "Fixed
ThreadPool (and dependent ORequestThread) life cycle" that still had some
problems:
* First, if Bridge::terminate was first entered from the reader or writer
thread, it would not join on that thread, so that thread could still be running
during exit.
That has been addressed by giving Bridge::dispose new semantics: It waits until
both Bridge::terminate has completed (even if that was called from a different
thread) and all spawned threads (reader, writer, ORequestThread workers) have
been joined. (This implies that Bridge::dispose must not be called from such a
thread, to avoid deadlock.)
* Second, if Bridge::terminate was first entered from an ORequestThread, the
call to uno_threadpool_dispose(0) to join on all such worker threads could
deadlock.
That has been addressed by making the last call to uno_threadpool_destroy wait
to join on all worker threads, and by calling uno_threadpool_destroy only from
the final Bridge::terminate (from Bridge::dispose), to avoid deadlock. (The
special semantics of uno_threadpool_dispose(0) are no longer needed and have
been removed, as they conflicted with the fix for the third problem below.)
* Third, once uno_threadpool_destroy had called uno_threadpool_dispose(0), the
ThreadAdmin singleton had been disposed, so no new remote bridges could
successfully be created afterwards.
That has been addressed by making ThreadAdmin a member of ThreadPool, and making
(only) those uno_ThreadPool handles with overlapping life spans share one
ThreadPool instance (which thus is no longer a singleton, either).
Additionally, ORequestThread has been made more robust (in the style of
salhelper::Thread) to avoid races.
Change-Id: I2cbd1b3f9aecc1bf4649e482d2c22b33b471788f
2012-05-23 09:42:37 +02:00
|
|
|
void remove( rtl::Reference< ORequestThread > const & );
|
|
|
|
void join();
|
|
|
|
|
|
|
|
void remove_locked( rtl::Reference< ORequestThread > const & );
|
|
|
|
::osl::Mutex m_mutex;
|
|
|
|
|
|
|
|
private:
|
2017-11-17 20:19:56 +01:00
|
|
|
std::deque< rtl::Reference< ORequestThread > > m_deque;
|
Better fix for ThreadPool/ORequestThread life cycle
This is a follow up to d015384e1d98fe77fd59339044f58efb1ab9fb25 "Fixed
ThreadPool (and dependent ORequestThread) life cycle" that still had some
problems:
* First, if Bridge::terminate was first entered from the reader or writer
thread, it would not join on that thread, so that thread could still be running
during exit.
That has been addressed by giving Bridge::dispose new semantics: It waits until
both Bridge::terminate has completed (even if that was called from a different
thread) and all spawned threads (reader, writer, ORequestThread workers) have
been joined. (This implies that Bridge::dispose must not be called from such a
thread, to avoid deadlock.)
* Second, if Bridge::terminate was first entered from an ORequestThread, the
call to uno_threadpool_dispose(0) to join on all such worker threads could
deadlock.
That has been addressed by making the last call to uno_threadpool_destroy wait
to join on all worker threads, and by calling uno_threadpool_destroy only from
the final Bridge::terminate (from Bridge::dispose), to avoid deadlock. (The
special semantics of uno_threadpool_dispose(0) are no longer needed and have
been removed, as they conflicted with the fix for the third problem below.)
* Third, once uno_threadpool_destroy had called uno_threadpool_dispose(0), the
ThreadAdmin singleton had been disposed, so no new remote bridges could
successfully be created afterwards.
That has been addressed by making ThreadAdmin a member of ThreadPool, and making
(only) those uno_ThreadPool handles with overlapping life spans share one
ThreadPool instance (which thus is no longer a singleton, either).
Additionally, ORequestThread has been made more robust (in the style of
salhelper::Thread) to avoid races.
Change-Id: I2cbd1b3f9aecc1bf4649e482d2c22b33b471788f
2012-05-23 09:42:37 +02:00
|
|
|
bool m_disposed;
|
|
|
|
};
|
|
|
|
|
2010-10-11 10:41:50 +01:00
|
|
|
class ThreadPool;
|
Better fix for ThreadPool/ORequestThread life cycle
This is a follow up to d015384e1d98fe77fd59339044f58efb1ab9fb25 "Fixed
ThreadPool (and dependent ORequestThread) life cycle" that still had some
problems:
* First, if Bridge::terminate was first entered from the reader or writer
thread, it would not join on that thread, so that thread could still be running
during exit.
That has been addressed by giving Bridge::dispose new semantics: It waits until
both Bridge::terminate has completed (even if that was called from a different
thread) and all spawned threads (reader, writer, ORequestThread workers) have
been joined. (This implies that Bridge::dispose must not be called from such a
thread, to avoid deadlock.)
* Second, if Bridge::terminate was first entered from an ORequestThread, the
call to uno_threadpool_dispose(0) to join on all such worker threads could
deadlock.
That has been addressed by making the last call to uno_threadpool_destroy wait
to join on all worker threads, and by calling uno_threadpool_destroy only from
the final Bridge::terminate (from Bridge::dispose), to avoid deadlock. (The
special semantics of uno_threadpool_dispose(0) are no longer needed and have
been removed, as they conflicted with the fix for the third problem below.)
* Third, once uno_threadpool_destroy had called uno_threadpool_dispose(0), the
ThreadAdmin singleton had been disposed, so no new remote bridges could
successfully be created afterwards.
That has been addressed by making ThreadAdmin a member of ThreadPool, and making
(only) those uno_ThreadPool handles with overlapping life spans share one
ThreadPool instance (which thus is no longer a singleton, either).
Additionally, ORequestThread has been made more robust (in the style of
salhelper::Thread) to avoid races.
Change-Id: I2cbd1b3f9aecc1bf4649e482d2c22b33b471788f
2012-05-23 09:42:37 +02:00
|
|
|
typedef rtl::Reference<ThreadPool> ThreadPoolHolder;
|
2010-10-11 10:41:50 +01:00
|
|
|
|
Better fix for ThreadPool/ORequestThread life cycle
This is a follow up to d015384e1d98fe77fd59339044f58efb1ab9fb25 "Fixed
ThreadPool (and dependent ORequestThread) life cycle" that still had some
problems:
* First, if Bridge::terminate was first entered from the reader or writer
thread, it would not join on that thread, so that thread could still be running
during exit.
That has been addressed by giving Bridge::dispose new semantics: It waits until
both Bridge::terminate has completed (even if that was called from a different
thread) and all spawned threads (reader, writer, ORequestThread workers) have
been joined. (This implies that Bridge::dispose must not be called from such a
thread, to avoid deadlock.)
* Second, if Bridge::terminate was first entered from an ORequestThread, the
call to uno_threadpool_dispose(0) to join on all such worker threads could
deadlock.
That has been addressed by making the last call to uno_threadpool_destroy wait
to join on all worker threads, and by calling uno_threadpool_destroy only from
the final Bridge::terminate (from Bridge::dispose), to avoid deadlock. (The
special semantics of uno_threadpool_dispose(0) are no longer needed and have
been removed, as they conflicted with the fix for the third problem below.)
* Third, once uno_threadpool_destroy had called uno_threadpool_dispose(0), the
ThreadAdmin singleton had been disposed, so no new remote bridges could
successfully be created afterwards.
That has been addressed by making ThreadAdmin a member of ThreadPool, and making
(only) those uno_ThreadPool handles with overlapping life spans share one
ThreadPool instance (which thus is no longer a singleton, either).
Additionally, ORequestThread has been made more robust (in the style of
salhelper::Thread) to avoid races.
Change-Id: I2cbd1b3f9aecc1bf4649e482d2c22b33b471788f
2012-05-23 09:42:37 +02:00
|
|
|
class ThreadPool: public salhelper::SimpleReferenceObject
|
2000-09-18 14:29:57 +00:00
|
|
|
{
|
|
|
|
public:
|
2010-10-11 10:41:50 +01:00
|
|
|
ThreadPool();
|
2016-09-13 13:09:01 +02:00
|
|
|
virtual ~ThreadPool() override;
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
void dispose( sal_Int64 nDisposeId );
|
2012-05-16 22:09:21 +02:00
|
|
|
void destroy( sal_Int64 nDisposeId );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2014-11-14 16:05:37 +01:00
|
|
|
bool addJob( const ::rtl::ByteSequence &aThreadId,
|
2014-02-15 17:39:35 +01:00
|
|
|
bool bAsynchron,
|
2000-09-18 14:29:57 +00:00
|
|
|
void *pThreadSpecificData,
|
2006-06-19 12:12:58 +00:00
|
|
|
RequestFun * doRequest );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
2014-05-19 00:36:42 +02:00
|
|
|
void prepare( const ::rtl::ByteSequence &aThreadId );
|
|
|
|
void * enter( const ::rtl::ByteSequence &aThreadId, sal_Int64 nDisposeId );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
/********
|
2011-12-08 09:05:20 +01:00
|
|
|
* @return true, if queue could be successfully revoked.
|
2000-09-18 14:29:57 +00:00
|
|
|
********/
|
2014-05-19 00:36:42 +02:00
|
|
|
bool revokeQueue( const ::rtl::ByteSequence & aThreadId , bool bAsynchron );
|
2000-09-18 14:29:57 +00:00
|
|
|
|
Better fix for ThreadPool/ORequestThread life cycle
This is a follow up to d015384e1d98fe77fd59339044f58efb1ab9fb25 "Fixed
ThreadPool (and dependent ORequestThread) life cycle" that still had some
problems:
* First, if Bridge::terminate was first entered from the reader or writer
thread, it would not join on that thread, so that thread could still be running
during exit.
That has been addressed by giving Bridge::dispose new semantics: It waits until
both Bridge::terminate has completed (even if that was called from a different
thread) and all spawned threads (reader, writer, ORequestThread workers) have
been joined. (This implies that Bridge::dispose must not be called from such a
thread, to avoid deadlock.)
* Second, if Bridge::terminate was first entered from an ORequestThread, the
call to uno_threadpool_dispose(0) to join on all such worker threads could
deadlock.
That has been addressed by making the last call to uno_threadpool_destroy wait
to join on all worker threads, and by calling uno_threadpool_destroy only from
the final Bridge::terminate (from Bridge::dispose), to avoid deadlock. (The
special semantics of uno_threadpool_dispose(0) are no longer needed and have
been removed, as they conflicted with the fix for the third problem below.)
* Third, once uno_threadpool_destroy had called uno_threadpool_dispose(0), the
ThreadAdmin singleton had been disposed, so no new remote bridges could
successfully be created afterwards.
That has been addressed by making ThreadAdmin a member of ThreadPool, and making
(only) those uno_ThreadPool handles with overlapping life spans share one
ThreadPool instance (which thus is no longer a singleton, either).
Additionally, ORequestThread has been made more robust (in the style of
salhelper::Thread) to avoid races.
Change-Id: I2cbd1b3f9aecc1bf4649e482d2c22b33b471788f
2012-05-23 09:42:37 +02:00
|
|
|
void waitInPool( rtl::Reference< ORequestThread > const & pThread );
|
|
|
|
|
|
|
|
void joinWorkers();
|
|
|
|
|
|
|
|
ThreadAdmin & getThreadAdmin() { return m_aThreadAdmin; }
|
|
|
|
|
2000-09-18 14:29:57 +00:00
|
|
|
private:
|
2014-11-14 16:05:37 +01:00
|
|
|
bool createThread( JobQueue *pQueue, const ::rtl::ByteSequence &aThreadId, bool bAsynchron);
|
2000-09-18 14:29:57 +00:00
|
|
|
|
|
|
|
|
|
|
|
ThreadIdHashMap m_mapQueue;
|
|
|
|
::osl::Mutex m_mutex;
|
|
|
|
|
|
|
|
::osl::Mutex m_mutexWaitingThreadList;
|
2017-11-17 20:19:56 +01:00
|
|
|
WaitingThreadDeque m_dequeThreads;
|
2010-10-11 10:41:50 +01:00
|
|
|
|
|
|
|
DisposedCallerAdminHolder m_DisposedCallerAdmin;
|
Better fix for ThreadPool/ORequestThread life cycle
This is a follow up to d015384e1d98fe77fd59339044f58efb1ab9fb25 "Fixed
ThreadPool (and dependent ORequestThread) life cycle" that still had some
problems:
* First, if Bridge::terminate was first entered from the reader or writer
thread, it would not join on that thread, so that thread could still be running
during exit.
That has been addressed by giving Bridge::dispose new semantics: It waits until
both Bridge::terminate has completed (even if that was called from a different
thread) and all spawned threads (reader, writer, ORequestThread workers) have
been joined. (This implies that Bridge::dispose must not be called from such a
thread, to avoid deadlock.)
* Second, if Bridge::terminate was first entered from an ORequestThread, the
call to uno_threadpool_dispose(0) to join on all such worker threads could
deadlock.
That has been addressed by making the last call to uno_threadpool_destroy wait
to join on all worker threads, and by calling uno_threadpool_destroy only from
the final Bridge::terminate (from Bridge::dispose), to avoid deadlock. (The
special semantics of uno_threadpool_dispose(0) are no longer needed and have
been removed, as they conflicted with the fix for the third problem below.)
* Third, once uno_threadpool_destroy had called uno_threadpool_dispose(0), the
ThreadAdmin singleton had been disposed, so no new remote bridges could
successfully be created afterwards.
That has been addressed by making ThreadAdmin a member of ThreadPool, and making
(only) those uno_ThreadPool handles with overlapping life spans share one
ThreadPool instance (which thus is no longer a singleton, either).
Additionally, ORequestThread has been made more robust (in the style of
salhelper::Thread) to avoid races.
Change-Id: I2cbd1b3f9aecc1bf4649e482d2c22b33b471788f
2012-05-23 09:42:37 +02:00
|
|
|
ThreadAdmin m_aThreadAdmin;
|
2000-09-18 14:29:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace cppu_threadpool
|
2010-10-14 08:30:07 +02:00
|
|
|
|
Better fix for ThreadPool/ORequestThread life cycle
This is a follow up to d015384e1d98fe77fd59339044f58efb1ab9fb25 "Fixed
ThreadPool (and dependent ORequestThread) life cycle" that still had some
problems:
* First, if Bridge::terminate was first entered from the reader or writer
thread, it would not join on that thread, so that thread could still be running
during exit.
That has been addressed by giving Bridge::dispose new semantics: It waits until
both Bridge::terminate has completed (even if that was called from a different
thread) and all spawned threads (reader, writer, ORequestThread workers) have
been joined. (This implies that Bridge::dispose must not be called from such a
thread, to avoid deadlock.)
* Second, if Bridge::terminate was first entered from an ORequestThread, the
call to uno_threadpool_dispose(0) to join on all such worker threads could
deadlock.
That has been addressed by making the last call to uno_threadpool_destroy wait
to join on all worker threads, and by calling uno_threadpool_destroy only from
the final Bridge::terminate (from Bridge::dispose), to avoid deadlock. (The
special semantics of uno_threadpool_dispose(0) are no longer needed and have
been removed, as they conflicted with the fix for the third problem below.)
* Third, once uno_threadpool_destroy had called uno_threadpool_dispose(0), the
ThreadAdmin singleton had been disposed, so no new remote bridges could
successfully be created afterwards.
That has been addressed by making ThreadAdmin a member of ThreadPool, and making
(only) those uno_ThreadPool handles with overlapping life spans share one
ThreadPool instance (which thus is no longer a singleton, either).
Additionally, ORequestThread has been made more robust (in the style of
salhelper::Thread) to avoid races.
Change-Id: I2cbd1b3f9aecc1bf4649e482d2c22b33b471788f
2012-05-23 09:42:37 +02:00
|
|
|
#endif
|
|
|
|
|
2010-10-14 08:30:07 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|