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 24 #ifndef TOOLKIT_INC_TOOLKIT_HELPER_SOLARRELEASE_HXX 25 #define TOOLKIT_INC_TOOLKIT_HELPER_SOLARRELEASE_HXX 26 27 #include <vcl/svapp.hxx> 28 29 //........................................................................ 30 namespace toolkit 31 { 32 //........................................................................ 33 34 //==================================================================== 35 //= ReleaseSolarMutex 36 //==================================================================== 37 class ReleaseSolarMutex 38 { 39 sal_uInt32 mnLockCount; 40 const bool mbRescheduleDuringAcquire; 41 42 public: 43 enum 44 { 45 RescheduleDuringAcquire = true 46 }; 47 48 public: ReleaseSolarMutex(const bool i_rescheduleDuringAcquire=false)49 ReleaseSolarMutex( const bool i_rescheduleDuringAcquire = false ) 50 :mnLockCount( Application::ReleaseSolarMutex() ) 51 ,mbRescheduleDuringAcquire( i_rescheduleDuringAcquire ) 52 { 53 54 } 55 ~ReleaseSolarMutex()56 ~ReleaseSolarMutex() 57 { 58 if ( mnLockCount > 0 ) 59 { 60 if ( mbRescheduleDuringAcquire ) 61 { 62 while ( !Application::GetSolarMutex().tryToAcquire() ) 63 { 64 Application::Reschedule(); 65 } 66 --mnLockCount; 67 } 68 Application::AcquireSolarMutex( mnLockCount ); 69 } 70 } 71 }; 72 73 //........................................................................ 74 } // namespace toolkit 75 //........................................................................ 76 77 #endif // TOOLKIT_INC_TOOLKIT_HELPER_SOLARRELEASE_HXX 78 79