Fawkes API Fawkes Development Version
syncpoint_manager.h
1/***************************************************************************
2 * syncpoint_manager.h - Fawkes SyncPointManager
3 *
4 * Created: Thu Jan 09 15:17:03 2014
5 * Copyright 2014 Till Hofmann
6 *
7 ****************************************************************************/
8
9/* This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Library General Public License for more details.
18 *
19 * Read the full text in the LICENSE.GPL file in the doc directory.
20 */
21
22#ifndef _SYNCPOINT_SYNCPOINT_MANAGER_H_
23#define _SYNCPOINT_SYNCPOINT_MANAGER_H_
24
25#include <core/threading/mutex.h>
26#include <core/utils/refptr.h>
27#include <logging/multi.h>
28#include <syncpoint/syncpoint.h>
29
30#include <set>
31#include <string>
32
33namespace fawkes {
34
35class SyncPoint;
36
38{
39public:
41 virtual ~SyncPointManager();
42
43 RefPtr<SyncPoint> get_syncpoint(const std::string &component, const std::string &identifier);
44 void release_syncpoint(const std::string &component, RefPtr<SyncPoint> syncpoint);
45
46 std::set<RefPtr<SyncPoint>, SyncPointSetLessThan> get_syncpoints();
47
48protected:
49 /** Set of all existing SyncPoints */
50 std::set<RefPtr<SyncPoint>, SyncPointSetLessThan> syncpoints_;
51 /** Mutex used for all SyncPointManager calls */
53
54private:
55 std::string find_prefix(const std::string &identifier) const;
56 RefPtr<SyncPoint> get_syncpoint_no_lock(const std::string &component,
57 const std::string &identifier);
58 void release_syncpoint_no_lock(const std::string &component, RefPtr<SyncPoint> syncpoint);
59 bool component_watches_any_successor(const RefPtr<SyncPoint> sp,
60 const std::string component) const;
61 MultiLogger *logger_;
62};
63
64} // end namespace fawkes
65
66#endif
Log through multiple loggers.
Definition: multi.h:35
Mutex mutual exclusion lock.
Definition: mutex.h:33
This class gives access to SyncPoints.
void release_syncpoint(const std::string &component, RefPtr< SyncPoint > syncpoint)
Release a SyncPoint.
std::set< RefPtr< SyncPoint >, SyncPointSetLessThan > get_syncpoints()
Get the current list of all SyncPoints managed by this SyncPointManager.
SyncPointManager(MultiLogger *logger)
Constructor.
Mutex * mutex_
Mutex used for all SyncPointManager calls.
std::set< RefPtr< SyncPoint >, SyncPointSetLessThan > syncpoints_
Set of all existing SyncPoints.
RefPtr< SyncPoint > get_syncpoint(const std::string &component, const std::string &identifier)
Get a SyncPoint.
Compare sets of syncpoints.
Definition: syncpoint.h:44
Fawkes library namespace.