[Click] a question about how to write elements

Harald Schioeberg harald at net.t-labs.tu-berlin.de
Mon Nov 29 02:46:36 EST 2010


On Mon, 2010-11-29 at 11:13 +0800, 刘晓佳 wrote:
> Hello,
> 
> I am new to click.I want to write my own elements.But I am puzzle over the
> mechannism of click,and have some questions, hope someone could give me
> help.
> 1、which function calls push function and other functions, such as cast
> function?


if you call "output(0)->push(p)" then this will call the push method of
the Element connected to output 0. 
(This is a bit oversimplified, but the magic in between can be safely
ignored) 

The only use of cast by click's internals is for the notifiers, if you
have things like queues that (a) have a pull output and (b) can run
empty.

In this case, under certain circumstances,
  Element::cast(EMPTY_NOTIFIER) 
is called and the notifier is used to avoid this kind of busy-looping: 

while (!p) { 
	p = input(0).pull() 
}

There are some very good tutorials/slides/exercises explaining that in
more detail here: 
http://www.pats.ua.ac.be/software/click

> 2、where can a function receive an actual parameter ?For example ,cast
> function and push function.

this one I don't understand, can you rephrase that? 

	
Best, 
	Harald






More information about the click mailing list