1 // -*- c-basic-offset: 4; related-file-name: "../../../elements/standard/scheduleinfo.cc" -*-
2 #ifndef CLICK_SCHEDULEINFO_HH
3 #define CLICK_SCHEDULEINFO_HH
4 #include <click/element.hh>
5 CLICK_DECLS
6 
7 /*
8 =c
9 
10 ScheduleInfo(ELEMENT PARAM, ...)
11 
12 =s information
13 
14 specifies scheduling parameters
15 
16 =io
17 
18 None
19 
20 =d
21 
22 Provides scheduling parameters for specified elements. Each configuration
23 argument has the form `ELEMENT PARAM', meaning that the element
24 named ELEMENT has scheduling parameter PARAM. Scheduling
25 parameters are real numbers that set how often one element should be
26 scheduled in relation to another. For example,
27 if elements A and B have
28 scheduling parameters 2 and 0.5, respectively, then A will be scheduled
29 2/0.5 = 4 times as often as B. The default scheduling parameter is 1.
30 
31 ScheduleInfo elements inside a compound element can specify scheduling
32 parameters for that compound's components.
33 Outer ScheduleInfo elements
34 can specify a ``scheduling parameter'' for the compound
35 element as a whole. This ``scheduling parameter'' is really a scaling
36 factor affecting the compound's components. For example, consider this
37 configuration,
38 
39    elementclass Compound {
40      i :: InfiniteSource -> output;
41      ScheduleInfo(i 0.5);
42    }
43    c :: Compound -> Discard;
44    ScheduleInfo(c 4);
45 
46 which is the same as the following configuration, after compound elements
47 are expanded.
48 
49    c/i :: InfiniteSource -> Discard@3 :: Discard;
50    c/ScheduleInfo@2 :: ScheduleInfo(i 0.5);
51    ScheduleInfo@4 :: ScheduleInfo(c 4);
52 
53 The name of the first ScheduleInfo element starts with `c/', so it is
54 used to look up scheduling parameters for elements named `c/I<whatever>'.
55 V<>(This includes all components of the compound element `c'.)
56 The second ScheduleInfo element, however, has no slash in its name,
57 so it is used to look up all scheduling parameters,
58 including scaling factors for compound elements.
59 The InfiniteSource's final scaling parameter will be 2:
60 the scaling factor 4 times the local scheduling parameter 0.5.
61 
62 An outer ScheduleInfo element can override local scheduling parameters.
63 For example, if the second ScheduleInfo element above was
64 
65    ScheduleInfo@4 :: ScheduleInfo(c 4, c/i 10.5)
66 
67 then the InfiniteSource's final scaling parameter would be 10.5.
68 */
69 
70 class ScheduleInfo : public Element { public:
71 
72     enum { FRAC_BITS = 10 };
73 
74     ScheduleInfo();
75 
class_name() const76     const char* class_name() const	{ return "ScheduleInfo"; }
77 
configure_phase() const78     int configure_phase() const		{ return CONFIGURE_PHASE_INFO; }
79     int configure(Vector<String>&, ErrorHandler*);
80 
81     bool query(const String&, int&) const;
82     bool query_prefixes(const String&, int&, String&) const;
83     static int query(Element*, ErrorHandler*);
84     static void initialize_task(Element*, Task*, bool sched, ErrorHandler*);
85     static void initialize_task(Element*, Task*, ErrorHandler*);
86     static void join_scheduler(Element*, Task*, ErrorHandler*);
87 
88 };
89 
90 
91 inline void
initialize_task(Element * e,Task * t,ErrorHandler * errh)92 ScheduleInfo::initialize_task(Element* e, Task* t, ErrorHandler* errh)
93 {
94     initialize_task(e, t, true, errh);
95 }
96 
97 inline void
join_scheduler(Element * e,Task * t,ErrorHandler * errh)98 ScheduleInfo::join_scheduler(Element* e, Task* t, ErrorHandler* errh)
99 {
100     initialize_task(e, t, true, errh);
101 }
102 
103 CLICK_ENDDECLS
104 #endif
105