Update ooo320-m1
[ooovba.git] / sw / source / core / docnode / swthreadmanager.cxx
blobfea0cd217cd88ebe7e752005723004172fea81ed
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: swthreadmanager.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #include "precompiled_sw.hxx"
31 #include <swthreadmanager.hxx>
32 #include <swthreadjoiner.hxx>
33 #include <observablethread.hxx>
34 #include <threadmanager.hxx>
36 /** class to manage threads in Writer - it conforms the singleton pattern
38 OD 2007-04-13 #i73788#
40 @author OD
42 SwThreadManager* SwThreadManager::mpThreadManager = 0;
43 osl::Mutex* SwThreadManager::mpGetManagerMutex = new osl::Mutex();
45 SwThreadManager::SwThreadManager()
46 : mpThreadManagerImpl( new ThreadManager( SwThreadJoiner::GetThreadJoiner() ) )
48 mpThreadManagerImpl->Init();
51 SwThreadManager::~SwThreadManager()
53 delete mpThreadManagerImpl;
56 SwThreadManager& SwThreadManager::GetThreadManager()
58 osl::MutexGuard aGuard(*mpGetManagerMutex);
60 if ( mpThreadManager == 0 )
62 mpThreadManager = new SwThreadManager();
65 return *mpThreadManager;
68 bool SwThreadManager::ExistsThreadManager()
70 return (mpThreadManager != 0);
73 oslInterlockedCount SwThreadManager::AddThread( const rtl::Reference< ObservableThread >& rThread )
75 return mpThreadManagerImpl->AddThread( rThread );
78 void SwThreadManager::RemoveThread( const oslInterlockedCount nThreadID )
80 mpThreadManagerImpl->RemoveThread( nThreadID );
83 void SwThreadManager::SuspendStartingOfThreads()
85 mpThreadManagerImpl->SuspendStartingOfThreads();
88 void SwThreadManager::ResumeStartingOfThreads()
90 mpThreadManagerImpl->ResumeStartingOfThreads();
93 bool SwThreadManager::StartingOfThreadsSuspended()
95 return mpThreadManagerImpl->StartingOfThreadsSuspended();