summaryrefslogtreecommitdiff
path: root/ACE/Kokyu/Kokyu_dsrt.h
blob: c2f202d34e0c50f0f3c3d85b3e0d04dc6b9e8b2f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/* -*- C++ -*- */
/**
 *  @file   Kokyu_dsrt.h
 *
 *  $Id$
 *
 *  @author Venkita Subramonian (venkita@cs.wustl.edu)
 *
 */

#ifndef KOKYU_DSRT_H
#define KOKYU_DSRT_H
#include /**/ "ace/pre.h"
#include "ace/Copy_Disabled.h"

#include "kokyu_export.h"
#include "Kokyu_defs.h"

namespace Kokyu
{

  template <class DSRT_Scheduler_Traits> class DSRT_Dispatcher_Impl;

  /**
   * @class DSRT_Dispatcher
   *
   * @brief Interface class for dynamic scheduling of threads
   *
   * The responsibility of this class is to forward all methods to
   * its delegation/implementation class, e.g.,
   * @c Default_DSRT_Dispatcher_Impl. This class follows the pImpl idiom
   * or the bridge pattern to separate the implementation from the interface.
   * DSRT_Dispatcher is the class that users will be using to achieve
   * dynamic scheduling of threads.
   */
  template <class DSRT_Scheduler_Traits>
  class DSRT_Dispatcher : private ACE_Copy_Disabled
  {
  public:
    typedef typename DSRT_Scheduler_Traits::Guid_t Guid_t;
    typedef typename DSRT_Scheduler_Traits::QoSDescriptor_t DSRT_QoSDescriptor;

    // = Scheduling methods.

    /// Schedule a thread dynamically based on the qos info supplied.
    int schedule (Guid_t guid, const DSRT_QoSDescriptor&);

    /// Update the schedule for a thread. This could alter the current schedule.
    int update_schedule (Guid_t guid, const DSRT_QoSDescriptor&);

    /// Inform the scheduler that the caller thread is about to
    /// block. This could alter the current schedule.
    int update_schedule (Guid_t guid, Kokyu::Block_Flag_t flag);

    /// Cancel the schedule for a thread. This could alter the current schedule.
    int cancel_schedule (Guid_t guid);

    /// Supply this interface with an appropriate implementation.
    void implementation (DSRT_Dispatcher_Impl<DSRT_Scheduler_Traits>*);

    // = Termination methods.

    /// Shut down the dispatcher. The dispatcher will stop processing requests.
    int shutdown ();

    /// Non virtual destructor. Read as <b><i>this class not available
    /// for inheritance<i></b>.
    ~DSRT_Dispatcher ();

  private:
    /// Auto ptr to the implementation. Implementation will be created on the
    /// heap and deleted automatically when the dispatcher object is destructed.
    auto_ptr<DSRT_Dispatcher_Impl<DSRT_Scheduler_Traits> > dispatcher_impl_;
  };


  /**
   * @class DSRT_Dispatcher_Factory
   *
   * @brief Factory class to create one of the dispatcher interface
   * objects - for events or DSRT threads.
   *
   * Factory class creates a dispatcher or DSRT dispatcher and configures
   * the interface object with the appropriate implementation.
   */

  template <class DSRT_Scheduler_Traits>
  class DSRT_Dispatcher_Factory : private ACE_Copy_Disabled
    {
    public:
      typedef auto_ptr<DSRT_Dispatcher<DSRT_Scheduler_Traits> > DSRT_Dispatcher_Auto_Ptr;

      /**
       * Create a dispatcher for dynamic dispatching of threads.
       * This will be used to dynamic scheduling of distributable threads for
       * DSRTCORBA. The caller is responsible for freeing the memory.
       *
       * @param config Configuration information for the DSRT dispatcher.
       *
       * @return pointer to the DSRT dispatcher.
       */
      static DSRT_Dispatcher<DSRT_Scheduler_Traits>* create_DSRT_dispatcher (const DSRT_ConfigInfo&);
    };

  /**
   * @class MIF_Sched_Strategy
   *
   * @brief Strategy class implementing Maximum Importance First
   * reordering strategy.
   *
   */
  template <class QoSDesc>
  class MIF_Comparator
  {
  public:
    typedef typename QoSDesc::Importance_t Importance_t;

    int operator ()(const QoSDesc& qos1,
                    const QoSDesc& qos2);
  };

  /**
   * @class Fixed_Priority_Sched_Strategy
   *
   * @brief Strategy class implementing Fixed Priority reordering
   * strategy.
   *
   */
  template <class QoSDesc>
  class Fixed_Priority_Comparator
  {
  public:
    typedef typename QoSDesc::Priority_t Priority_t;

    int operator ()(const QoSDesc& qos1,
                    const QoSDesc& qos2);
  };

  /**
   * @class MUF_Sched_Strategy
   *
   * @brief Strategy class implementing Maximum Urgency First
   * reordering strategy.
   *
   */
  template <class QoSDesc>
  class MUF_Comparator
  {
    public:
    typedef typename QoSDesc::Criticality_t Criticality_t;
    typedef typename QoSDesc::Time_t Time_t;

    int operator ()(const QoSDesc& qos1,
                    const QoSDesc& qos2);
  };


} //end of namespace

#if defined (__ACE_INLINE__)
#include "Kokyu_dsrt.inl"
#endif /* __ACE_INLINE__ */

#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "Kokyu_dsrt.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */

#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("Kokyu_dsrt.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */

#include /**/ "ace/post.h"
#endif /* KOKYU_DSRT_H */