Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
callback-guard.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  * Contact: Piotr Bartosiewicz <p.bartosiewi@partner.samsung.com>
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License
17  */
18 
25 #ifndef COMMON_UTILS_CALLBACK_GUARD_HPP
26 #define COMMON_UTILS_CALLBACK_GUARD_HPP
27 
28 
29 #include <memory>
30 
31 
32 namespace utils {
33 
39 public:
40  typedef std::shared_ptr<void> Tracker;
41 
45  CallbackGuard();
46 
51 
55  Tracker spawn() const;
56 
60  long getTrackersCount() const;
61 
65  bool waitForTrackers(const unsigned int timeoutMs);
66 private:
67  class SharedState;
68  std::shared_ptr<SharedState> mSharedState;
69 
70  CallbackGuard(const CallbackGuard&) = delete;
71  CallbackGuard& operator=(const CallbackGuard&) = delete;
72 };
73 
74 } // namespace utils
75 
76 
77 #endif // COMMON_UTILS_CALLBACK_GUARD_HPP
bool waitForTrackers(const unsigned int timeoutMs)
Wait for all trackers.
Definition: callback-guard.cpp:123
std::shared_ptr< void > Tracker
Definition: callback-guard.hpp:40
Tracker spawn() const
Creates a tracker.
Definition: callback-guard.cpp:113
Callback guard.
Definition: callback-guard.hpp:38
CallbackGuard & operator=(const CallbackGuard &)=delete
~CallbackGuard()
Waits for all trackers.
Definition: callback-guard.cpp:105
Definition: callback-guard.cpp:37
std::shared_ptr< SharedState > mSharedState
Definition: callback-guard.hpp:67
CallbackGuard()
Creates a guard.
Definition: callback-guard.cpp:100
long getTrackersCount() const
Gets trackers count.
Definition: callback-guard.cpp:118