⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 drivermanager.hh

📁 COPE the first practical network coding scheme which is developped on click
💻 HH
字号:
// -*- c-basic-offset: 4; related-file-name: "../../../elements/standard/drivermanager.cc" -*-#ifndef CLICK_DRIVERMANAGER_HH#define CLICK_DRIVERMANAGER_HH#include <click/element.hh>#include <click/timer.hh>CLICK_DECLS/*=cDriverManager(INSTRUCTIONS...)=s informationmanages driver stop events=ioNone=dThe DriverManager element gives you control over when the Click driver shouldstop.Click I<driver stop events> suggest that the driver should stop processing.Any element can register a driver stop event; for instance, trace processingelements can stop the driver when they finish a trace file.  You generallyrequest this functionality by supplying a 'STOP true' keyword argument.Driver stop events normally stop the driver: the user-level driver callsC<exit(0)>, or the kernel driver kills the relevant kernel threads.  TheDriverManager element changes this behavior.  When a driver stop event occurs,the router asks DriverManager what to do next.  Depending on its arguments,DriverManager will tell the driver to stop immediately, to wait a while, or tocontinue until the next driver stop event, possibly after calling handlers onother elements.Each configuration argument is an I<instruction>; DriverManager processesthese instructions sequentially. Instructions include:=over 8=item 'C<stop>'Stop the driver.=item 'C<wait>'Consume a driver stop event, then go to the next instruction.=item 'C<wait_time> TIME'Wait for TIME seconds, or until a driver stop event occurs, whichever comesfirst; then go to the next instruction.  Any driver stop is not consumed.TIME has microsecond precision.=item 'C<wait_stop> [COUNT]'Consume COUNT driver stop events, then go to the next instruction.  COUNTdefaults to one.=item 'C<read> HANDLER'Call a read handler and print the result.  HANDLER will either be a globalhandler, such as 'C<config>', or an element handler, such as 'C<c.count>'.=item 'C<write> HANDLER [ARG...]'Call a write handler, then go to the next instruction.  ARGs, if supplied, arepassed to the handler as is.=item 'C<write_skip> HANDLER [ARG]'Same as 'C<write>', except that this directive is skipped when there isanother driver stop event pending.=backThe user level driver supports three additional instructions:=over 8=item 'C<save> HANDLER FILE'Call a read handler and save the result to FILE.  If FILE is 'C<->' oromitted, writes the handler value to the standard output.=item 'C<append> HANDLER FILE'Call a read handler and append the result to FILE.  IfFILE is 'C<->', writes the handler value to the standard output.=item 'C<loop>'Starts over from the first directive.=backDriverManager adds an implicit 'C<stop>' instruction to the end of itsinstruction list. As a special case, 'C<DriverManager()>', with no arguments,is equivalent to 'C<DriverManager(wait_stop, stop)>'.DriverManager accepts the following keyword argument:=over 8=item CHECK_HANDLERSBoolean. If false, then DriverManager will ignore bad handler names, ratherthan failing to initialize. Default is true.=backA router configuration can contain at most one DriverManager element.=eThe following DriverManager element ensures that an element, C<k>, has time toclean itself up before the driver is stopped. It waits for the first driverstop event, then calls C<k>'s C<cleanup> handler, waits for a tenth of asecond, and stops the driver.  DriverManager(wait_stop, write k.cleanup, wait_time 0.1, stop);Use this idiom when one of your elements must emit a last packet or two beforethe router configuration is destroyed.*/class DriverManager : public Element { public:    DriverManager();    ~DriverManager();    const char *class_name() const	{ return "DriverManager"; }    int configure(Vector<String> &, ErrorHandler *);    int initialize(ErrorHandler *);    void run_timer();    virtual bool handle_stopped_driver();    int stopped_count() const		{ return _stopped_count; }  private:    enum Insn { INSN_INITIAL, INSN_WAIT_STOP, INSN_WAIT_TIME, // order required		INSN_READ, INSN_WRITE, INSN_WRITE_SKIP, INSN_SAVE, INSN_APPEND,		INSN_IGNORE, INSN_STOP, INSN_GOTO };    Vector<int> _insns;    Vector<int> _args;    Vector<int> _args2;    Vector<String> _args3;    int _insn_pos;    int _stopped_count;    bool _check_handlers;    Timer _timer;    void add_insn(int, int, int = 0, const String & = String());    bool step_insn();};CLICK_ENDDECLS#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -