| 487 | } |
| 488 | |
| 489 | inline void Module::RunChooseModule(Context *ctx, gate_idx_t ogate_idx, |
| 490 | bess::PacketBatch *batch) { |
| 491 | bess::OGate *ogate; |
| 492 | |
| 493 | if (unlikely(batch->cnt() <= 0)) { |
| 494 | return; |
| 495 | } |
| 496 | |
| 497 | if (unlikely(ogate_idx >= ogates_.size())) { |
| 498 | deadend(ctx, batch); |
| 499 | return; |
| 500 | } |
| 501 | |
| 502 | ogate = ogates_[ogate_idx]; |
| 503 | |
| 504 | if (unlikely(!ogate)) { |
| 505 | deadend(ctx, batch); |
| 506 | return; |
| 507 | } |
| 508 | |
| 509 | for (auto &hook : ogate->hooks()) { |
| 510 | hook->ProcessBatch(batch); |
| 511 | } |
| 512 | |
| 513 | ctx->task->AddToRun(ogate->igate(), batch); |
| 514 | } |
| 515 | |
| 516 | inline void Module::RunNextModule(Context *ctx, bess::PacketBatch *batch) { |
| 517 | RunChooseModule(ctx, 0, batch); |