1*b557fc96SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*b557fc96SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*b557fc96SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*b557fc96SAndrew Rist  * distributed with this work for additional information
6*b557fc96SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*b557fc96SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*b557fc96SAndrew Rist  * "License"); you may not use this file except in compliance
9*b557fc96SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*b557fc96SAndrew Rist  *
11*b557fc96SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*b557fc96SAndrew Rist  *
13*b557fc96SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*b557fc96SAndrew Rist  * software distributed under the License is distributed on an
15*b557fc96SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b557fc96SAndrew Rist  * KIND, either express or implied.  See the License for the
17*b557fc96SAndrew Rist  * specific language governing permissions and limitations
18*b557fc96SAndrew Rist  * under the License.
19*b557fc96SAndrew Rist  *
20*b557fc96SAndrew Rist  *************************************************************/
21*b557fc96SAndrew Rist 
22*b557fc96SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_fpicker.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <vcl/svapp.hxx>
28cdf0e10cSrcweir #include <vos/mutex.hxx>
29cdf0e10cSrcweir #include <osl/thread.hxx>
30cdf0e10cSrcweir 
ReleaseSolarMutexOnMainThreadContext(unsigned nThreadId)31cdf0e10cSrcweir int ReleaseSolarMutexOnMainThreadContext(unsigned nThreadId)
32cdf0e10cSrcweir {
33cdf0e10cSrcweir 	int nAcquireCount = 0;
34cdf0e10cSrcweir 	vos::IMutex& rSolarMutex = Application::GetSolarMutex();
35cdf0e10cSrcweir 	vos::OThread::TThreadIdentifier nMainThreadId = Application::GetMainThreadIdentifier();
36cdf0e10cSrcweir 
37cdf0e10cSrcweir 	if ( nMainThreadId == nThreadId )
38cdf0e10cSrcweir 	{
39cdf0e10cSrcweir 		::vos::IMutex& rMutex = Application::GetSolarMutex();
40cdf0e10cSrcweir 		if ( rMutex.tryToAcquire() )
41cdf0e10cSrcweir 			nAcquireCount = Application::ReleaseSolarMutex() - 1;
42cdf0e10cSrcweir 	}
43cdf0e10cSrcweir 
44cdf0e10cSrcweir 	return nAcquireCount;
45cdf0e10cSrcweir }
46cdf0e10cSrcweir 
AcquireSolarMutex(int nAcquireCount)47cdf0e10cSrcweir void AcquireSolarMutex(int nAcquireCount)
48cdf0e10cSrcweir {
49cdf0e10cSrcweir 	if ( nAcquireCount )
50cdf0e10cSrcweir         Application::AcquireSolarMutex( nAcquireCount );
51cdf0e10cSrcweir }
52