Fawkes API  Fawkes Development Version
syncpoint.cpp
1 /***************************************************************************
2  * syncpoint.cpp - SyncPoint Aspect initializer/finalizer
3  *
4  * Created: Thu Feb 19 14:39:42 2015
5  * Copyright 2015 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 #include <aspect/inifins/syncpoint.h>
23 #include <aspect/syncpoint.h>
24 #include <syncpoint/syncpoint_manager.h>
25 
26 namespace fawkes {
27 
28 /** @class SyncPointAspectIniFin <aspect/inifins/syncpoint.h>
29  * Initializer/finalizer for the SyncPointAspect
30  * @author Till Hofmann
31  */
32 
33 /** Constructor.
34  * @param syncpoint_manager SyncPointManager instance to pass to threads
35  */
37 : AspectIniFin("SyncPointAspect")
38 {
39  syncpoint_manager_ = syncpoint_manager;
40 }
41 
42 void
44 {
45  SyncPointAspect *syncpoint_thread;
46  syncpoint_thread = dynamic_cast<SyncPointAspect *>(thread);
47  if (syncpoint_thread == NULL) {
48  throw CannotInitializeThreadException("Thread '%s' claims to have the "
49  "SyncPointManagerAspect, but RTTI says it "
50  "has not. ",
51  thread->name());
52  }
53 
54  syncpoint_thread->init_SyncPointAspect(thread, syncpoint_manager_);
55 }
56 
57 void
59 {
60  SyncPointAspect *syncpoint_thread;
61  syncpoint_thread = dynamic_cast<SyncPointAspect *>(thread);
62  if (syncpoint_thread == NULL) {
63  throw CannotInitializeThreadException("Thread '%s' claims to have the "
64  "SyncPointManagerAspect, but RTTI says it "
65  "has not. ",
66  thread->name());
67  }
68 
69  syncpoint_thread->finalize_SyncPointAspect(thread, syncpoint_manager_);
70 }
71 
72 } // end namespace fawkes
Fawkes library namespace.
void init_SyncPointAspect(Thread *thread, SyncPointManager *syncpoint_manager)
Init SyncPoint aspect.
Definition: syncpoint.cpp:87
SyncPointAspectIniFin(SyncPointManager *syncpoint_manager)
Constructor.
Definition: syncpoint.cpp:36
Thread class encapsulation of pthreads.
Definition: thread.h:45
Thread aspect to acces to SyncPoints Give this aspect to your thread to manage SyncPoints,...
Definition: syncpoint.h:34
This class gives access to SyncPoints.
const char * name() const
Get name of thread.
Definition: thread.h:100
virtual void init(Thread *thread)
Initialize thread.
Definition: syncpoint.cpp:43
void finalize_SyncPointAspect(Thread *thread, SyncPointManager *syncpoint_manager)
Finalize SyncPoint aspect.
Definition: syncpoint.cpp:109
virtual void finalize(Thread *thread)
Finalize thread.
Definition: syncpoint.cpp:58
Aspect initializer/finalizer base class.
Definition: inifin.h:33