📄 drivermanager.hh
字号:
// -*- c-basic-offset: 4; related-file-name: "../../../elements/standard/drivermanager.cc" -*-#ifndef CLICK_DRIVERMANAGER_HH#define CLICK_DRIVERMANAGER_HH#include "script.hh"CLICK_DECLS/*=cDriverManager(INSTRUCTIONS...)=s controla Script that manages driver stop events=dDriverManager is simply a Script element whose default TYPE is "C<DRIVER>".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 steps through the DriverManager's script by calling its C<step>handler. The driver exits only when the script ends or a C<stop> instructionis executed.For example, the following DriverManager element ensures that an element,C<k>, has time to clean itself up before the driver is stopped. It waits forthe first driver stop event, then calls C<k>'s C<cleanup> handler, waits for atenth of a second, and stops the driver. DriverManager(pause, write k.cleanup, wait 0.1s, stop);Use this idiom when one of your elements must emit a last packet or two beforethe router configuration is destroyed.=a Script*/class DriverManager : public Script { public: DriverManager(); const char *class_name() const { return "DriverManager"; }};/* XXX=nThe driver's step instructions have a special property: If the driver stopswhile the script is paused at a C<wait> instruction, then the script will makeI<two> steps, rather than one. To understand this difference, consider thefollowing two scripts: (1) s::Script(wait 1s, print "before", pause, print "after"); Script(wait 0.5s, write s.step) (2) DriverManager(wait 1s, print "before", pause, print "after"); Script(wait 0.5s, write stop)The first script will wait 0.5s, print "before" (because the second script hasstepped the first script past its C<wait> instruction), then block at theC<pause> instruction. The second script will wait 0.5s, then print "before",Do not rely on this functionality, since we may change it soon.*/CLICK_ENDDECLS#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -