1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #include "precompiled_sw.hxx"
24 #include <swthreadmanager.hxx>
25 #include <swthreadjoiner.hxx>
26 #include <observablethread.hxx>
27 #include <threadmanager.hxx>
28 
29 /** class to manage threads in Writer - it conforms the singleton pattern
30 
31     OD 2007-04-13 #i73788#
32 
33     @author OD
34 */
35 bool SwThreadManager::mbThreadManagerInstantiated = false;
36 
SwThreadManager()37 SwThreadManager::SwThreadManager()
38     : mpThreadManagerImpl( new ThreadManager( SwThreadJoiner::GetThreadJoiner() ) )
39 {
40     mpThreadManagerImpl->Init();
41     mbThreadManagerInstantiated = true;
42 }
43 
~SwThreadManager()44 SwThreadManager::~SwThreadManager()
45 {
46 }
47 
48 struct InitInstance : public rtl::Static<SwThreadManager, InitInstance> {};
49 
GetThreadManager()50 SwThreadManager& SwThreadManager::GetThreadManager()
51 {
52     return InitInstance::get();
53 }
54 
ExistsThreadManager()55 bool SwThreadManager::ExistsThreadManager()
56 {
57     return mbThreadManagerInstantiated;
58 }
59 
AddThread(const rtl::Reference<ObservableThread> & rThread)60 oslInterlockedCount SwThreadManager::AddThread( const rtl::Reference< ObservableThread >& rThread )
61 {
62     return mpThreadManagerImpl->AddThread( rThread );
63 }
64 
RemoveThread(const oslInterlockedCount nThreadID)65 void SwThreadManager::RemoveThread( const oslInterlockedCount nThreadID )
66 {
67     mpThreadManagerImpl->RemoveThread( nThreadID );
68 }
69 
SuspendStartingOfThreads()70 void SwThreadManager::SuspendStartingOfThreads()
71 {
72     mpThreadManagerImpl->SuspendStartingOfThreads();
73 }
74 
ResumeStartingOfThreads()75 void SwThreadManager::ResumeStartingOfThreads()
76 {
77     mpThreadManagerImpl->ResumeStartingOfThreads();
78 }
79 
StartingOfThreadsSuspended()80 bool SwThreadManager::StartingOfThreadsSuspended()
81 {
82     return mpThreadManagerImpl->StartingOfThreadsSuspended();
83 }
84