what does this Task * mean???

Sep 23, 2011 at 3:15am
The code is like following, Task is a class,what does that (Task *) mean here??

class InfiniteSource { ...
bool run_task(Task *t);
private:
Task _task;
};

InfiniteSource::InfiniteSource() : _task(this) {
}

int InfiniteSource::initialize(ErrorHandler *errh) {
ScheduleInfo::initialize_task(this, &_task, errh);
return 0;
}

bool InfiniteSource::run_task(Task *) {
Packet *p = ... generate packet ...;
output(0).push(p);
if (packets left to send)
_task.fast_reschedule();
return true; // the task did useful work
}
Last edited on Sep 23, 2011 at 3:17am
Sep 23, 2011 at 3:26am
It's a pointer to a Task object.
Sep 23, 2011 at 3:42am
but why there is no parameter appeared???
Sep 23, 2011 at 4:41am
It means that although you pass a Task*, they never use it (and thus don't have to name it). Kind of dumb to have a parameter that you don't use though.
Sep 23, 2011 at 2:31pm
If you don‘t use it,why bother pass it????
Sep 23, 2011 at 5:57pm
Ask the one who wrote that code or check the documentation (if there is one) to see what the parameter's purpose is.
Something like this can happen when you override a virtual function, but don't care about its parameter. However, since InfiniteSource apparently doesn't inherit from anything, this doesn't seem to be the case here.
Topic archived. No new replies allowed.