Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef __FRAMEWORK_THREADHELP_THREADHELPBASE_HXX_
21 : #define __FRAMEWORK_THREADHELP_THREADHELPBASE_HXX_
22 :
23 : #include <threadhelp/lockhelper.hxx>
24 :
25 : namespace framework{
26 :
27 : /*-************************************************************************************************************//**
28 : @short "baseclass" to make own classes threadsafe
29 : @descr Sometimes you must share your lock- or mutex member with any other baseclasses.
30 : And baseclasses are initialized erlier then members! That's why you should use
31 : this struct as first of your baseclasses!!!
32 : Then you will get a public member "m_aLock" which can be used by special guard implementations
33 : to make your code threadsafe.
34 :
35 : @seealso class LockHelper
36 :
37 : @implements -
38 : @base -
39 :
40 : @devstatus ready to use
41 : *//*-*************************************************************************************************************/
42 30422 : struct ThreadHelpBase
43 : {
44 : //-------------------------------------------------------------------------------------------------------------
45 : // public methods
46 : //-------------------------------------------------------------------------------------------------------------
47 : public:
48 36263 : ThreadHelpBase( ::osl::SolarMutex* pSolarMutex = NULL )
49 36263 : : m_aLock( pSolarMutex )
50 : {
51 36263 : }
52 :
53 : //-------------------------------------------------------------------------------------------------------------
54 : // public member
55 : // Make it mutable for using in const functions!
56 : //-------------------------------------------------------------------------------------------------------------
57 : public:
58 :
59 : mutable LockHelper m_aLock;
60 : };
61 :
62 : } // namespace framework
63 :
64 : #endif // #ifndef __FRAMEWORK_THREADHELP_THREADHELPBASE_HXX_
65 :
66 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|