Merge pull request #1844 from jrw972/monterey
[ACE_TAO.git] / TAO / orbsvcs / performance-tests / RTEvent / lib / Task_Activator.h
blob5a8f9ecf2b5c3ffac19c333254734476cde477d3
1 /**
2 * @file Task_Activator.h
4 * @author Carlos O'Ryan <coryan@uci.edu>
5 */
7 #ifndef TAO_PERF_RTEC_TASK_ACTIVATOR_H
8 #define TAO_PERF_RTEC_TASK_ACTIVATOR_H
10 #include "ace/Task.h"
11 #include "ace/Copy_Disabled.h"
13 #if !defined (ACE_LACKS_PRAGMA_ONCE)
14 # pragma once
15 #endif /* ACE_LACKS_PRAGMA_ONCE */
17 /**
18 * @class Task_Activator
20 * @brief Simplify the activation and destruction of tasks
22 template<class Task>
23 class Task_Activator : private ACE_Copy_Disabled
25 public:
26 /// Constructor
27 /**
28 * @todo If we were to define a generic ACE class for this then we
29 * should certainly change the constructor. For example, we
30 * should pass an structure with all the thread activation
31 * arguments, like:<BR>
32 * Activation_Properties properties;<BR>
33 * Task_Activator<Foo> activator (properties, foo);<BR>
34 * <BR>
35 * The advantage of using an structure instead of a long list
36 * of arguments is that the user can change some of the
37 * defaults without having to know all the other values, plus
38 * it evolves better: over time if arguments are added the
39 * client code does not change.<BR>
40 * <BR>
41 * With a little trickery we can even change the arguments in
42 * a single line:<BR>
43 * Activation_Properties props ().priority (x).stack_size (y);<BR>
44 * <BR>
45 * all you need to do is return <CODE>*this</CODE> from each
46 * modifier.
49 Task_Activator (int priority,
50 int scheduling_class,
51 int nthreads,
52 Task *task);
54 /// Destructor
55 /**
56 * Wait until the task terminates before returning, this is useful
57 * in programs that need to guarantee that the task object is not
58 * destroyed before the underlying threads finished.
59 * However, the use of this class implicitly requires that the task
60 * will eventually terminate!
62 * Sometimes it is better to derive from this class and implement a
63 * cooperative termination protocol in the destructor of the derived
64 * class.
66 ~Task_Activator (void);
68 /// Release the task, do not terminate it
69 void release (void);
71 protected:
72 Task *task_;
75 #if defined(__ACE_INLINE__)
76 #include "Task_Activator.inl"
77 #endif /* __ACE_INLINE__ */
79 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
80 #include "Task_Activator.cpp"
81 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
83 #endif /* TAO_PERF_RTEC_TASK_ACTIVATOR_H */