ParseContext.cxx (f6e50924) ParseContext.cxx (2fe9d24a)
1/**************************************************************
1/**************************************************************
2 *
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
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 *
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
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.
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 *
19 *
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_svx.hxx"
26
27#include "svx/ParseContext.hxx"

--- 150 unchanged lines hidden (view full) ---

178}
179
180
181// =============================================================================
182// =============================================================================
183namespace
184{
185 // -----------------------------------------------------------------------------
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_svx.hxx"
26
27#include "svx/ParseContext.hxx"

--- 150 unchanged lines hidden (view full) ---

178}
179
180
181// =============================================================================
182// =============================================================================
183namespace
184{
185 // -----------------------------------------------------------------------------
186 ::osl::Mutex& getSafteyMutex()
186 ::osl::Mutex& getSafetyMutex()
187 {
188 static ::osl::Mutex s_aSafety;
189 return s_aSafety;
190 }
191 // -----------------------------------------------------------------------------
192 oslInterlockedCount& getCounter()
193 {
194 static oslInterlockedCount s_nCounter;

--- 16 unchanged lines hidden (view full) ---

211 }
212 return s_pSharedContext;
213 }
214 // -----------------------------------------------------------------------------
215}
216// -----------------------------------------------------------------------------
217OParseContextClient::OParseContextClient()
218{
187 {
188 static ::osl::Mutex s_aSafety;
189 return s_aSafety;
190 }
191 // -----------------------------------------------------------------------------
192 oslInterlockedCount& getCounter()
193 {
194 static oslInterlockedCount s_nCounter;

--- 16 unchanged lines hidden (view full) ---

211 }
212 return s_pSharedContext;
213 }
214 // -----------------------------------------------------------------------------
215}
216// -----------------------------------------------------------------------------
217OParseContextClient::OParseContextClient()
218{
219 ::osl::MutexGuard aGuard( getSafteyMutex() );
219 ::osl::MutexGuard aGuard( getSafetyMutex() );
220 if ( 1 == osl_incrementInterlockedCount( &getCounter() ) )
221 { // first instance
222 getSharedContext( new OSystemParseContext );
223 }
224}
225
226// -----------------------------------------------------------------------------
227OParseContextClient::~OParseContextClient()
228{
229 {
220 if ( 1 == osl_incrementInterlockedCount( &getCounter() ) )
221 { // first instance
222 getSharedContext( new OSystemParseContext );
223 }
224}
225
226// -----------------------------------------------------------------------------
227OParseContextClient::~OParseContextClient()
228{
229 {
230 ::osl::MutexGuard aGuard( getSafteyMutex() );
230 ::osl::MutexGuard aGuard( getSafetyMutex() );
231 if ( 0 == osl_decrementInterlockedCount( &getCounter() ) )
232 delete getSharedContext(NULL,sal_True);
233 }
234}
235// -----------------------------------------------------------------------------
236const OSystemParseContext* OParseContextClient::getParseContext() const
237{
238 return getSharedContext();
239}
240// -----------------------------------------------------------------------------
231 if ( 0 == osl_decrementInterlockedCount( &getCounter() ) )
232 delete getSharedContext(NULL,sal_True);
233 }
234}
235// -----------------------------------------------------------------------------
236const OSystemParseContext* OParseContextClient::getParseContext() const
237{
238 return getSharedContext();
239}
240// -----------------------------------------------------------------------------
241
242
243
244
245