INET Framework for OMNeT++/OMNEST
inet::queueing::PreemptingServer Class Reference

#include <PreemptingServer.h>

Inheritance diagram for inet::queueing::PreemptingServer:
inet::ClockUserModuleMixin< PacketServerBase > inet::queueing::PacketServerBase inet::queueing::PacketProcessorBase inet::queueing::IActivePacketSink inet::queueing::IActivePacketSource inet::queueing::IPacketProcessor inet::StringFormat::IDirectiveResolver

Public Member Functions

virtual ~PreemptingServer ()
 
virtual void handleCanPushPacketChanged (cGate *gate) override
 Notifies about a change in the possibility of pushing some packet into the passive packet sink at the given gate. More...
 
virtual void handleCanPullPacketChanged (cGate *gate) override
 Notifies about a change in the possibility of pulling some packet from the passive packet source at the given gate. More...
 
virtual void handlePushPacketProcessed (Packet *packet, cGate *gate, bool successful) override
 Notifies about the completion of the packet processing for a packet that was pushed earlier independently whether the packet is passed or streamed. More...
 
- Public Member Functions inherited from inet::ClockUserModuleMixin< PacketServerBase >
virtual void scheduleClockEventAt (clocktime_t time, ClockEvent *msg)
 
virtual void scheduleClockEventAfter (clocktime_t delay, ClockEvent *msg)
 
virtual cMessage * cancelClockEvent (ClockEvent *msg)
 
virtual void cancelAndDeleteClockEvent (ClockEvent *msg)
 
virtual void rescheduleClockEventAt (clocktime_t time, ClockEvent *msg)
 
virtual void rescheduleClockEventAfter (clocktime_t time, ClockEvent *msg)
 
virtual clocktime_t computeClockTimeFromSimTime (simtime_t time) const
 
virtual simtime_t computeSimTimeFromClockTime (clocktime_t time) const
 
virtual clocktime_t getClockTime () const
 
virtual clocktime_t getArrivalClockTime (ClockEvent *msg) const
 
- Public Member Functions inherited from inet::queueing::PacketServerBase
virtual IPassivePacketSourcegetProvider (cGate *gate) override
 Returns the passive packet source from where packets are pulled or nullptr if the connected module doesn't implement the interface. More...
 
virtual IPassivePacketSinkgetConsumer (cGate *gate) override
 Returns the passive packet sink where packets are pushed or nullptr if the connected module doesn't implement the interface. More...
 
virtual bool supportsPacketPushing (cGate *gate) const override
 Returns true if the processor supports pushing packets at the given gate. More...
 
virtual bool supportsPacketPulling (cGate *gate) const override
 Returns true if the processor supports pulling packets at the given gate. More...
 
virtual void handlePullPacketProcessed (Packet *packet, cGate *gate, bool successful) override
 Notifies about the completion of the packet processing for a packet that was pulled earlier independently whether the packet is passed or streamed. More...
 
- Public Member Functions inherited from inet::queueing::PacketProcessorBase
virtual bool supportsPacketSending (cGate *gate) const override
 Returns true if the processor supports sending packets at the given gate. More...
 
virtual bool supportsPacketPassing (cGate *gate) const override
 Returns true if the processor supports passing packets as a whole at the given gate. More...
 
virtual bool supportsPacketStreaming (cGate *gate) const override
 Returns true if the processor supports streaming packets at the given gate. More...
 
virtual const char * resolveDirective (char directive) const override
 
- Public Member Functions inherited from inet::queueing::IPacketProcessor
virtual ~IPacketProcessor ()
 
- Public Member Functions inherited from inet::queueing::IActivePacketSink
virtual ~IActivePacketSink ()
 
- Public Member Functions inherited from inet::queueing::IActivePacketSource
virtual ~IActivePacketSource ()
 

Protected Member Functions

virtual void initialize (int stage) override
 
virtual void handleMessage (cMessage *message) override
 
virtual bool isStreaming () const
 
virtual bool canStartStreaming () const
 
virtual void startStreaming ()
 
virtual void endStreaming ()
 
- Protected Member Functions inherited from inet::queueing::PacketProcessorBase
virtual int numInitStages () const override
 
virtual void refreshDisplay () const override
 
virtual void handlePacketProcessed (Packet *packet)
 
virtual void checkPacketOperationSupport (cGate *gate) const
 
virtual void checkPacketOperationSupport (cGate *startGate, cGate *endGate) const
 
virtual void animate (Packet *packet, cGate *gate, const SendOptions &sendOptions, Action action) const
 
virtual void animatePacket (Packet *packet, cGate *gate, Action action) const
 
virtual void animatePacketStart (Packet *packet, cGate *gate, bps datarate, long transmissionId, Action action) const
 
virtual void animatePacketStart (Packet *packet, cGate *gate, bps datarate, const SendOptions &sendOptions, Action action) const
 
virtual void animatePacketEnd (Packet *packet, cGate *gate, long transmissionId, Action action) const
 
virtual void animatePacketEnd (Packet *packet, cGate *gate, const SendOptions &sendOptions, Action action) const
 
virtual void animatePacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, long transmissionId, Action action) const
 
virtual void animatePacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, const SendOptions &sendOptions, Action action) const
 
virtual void pushOrSendPacket (Packet *packet, cGate *gate, IPassivePacketSink *consumer)
 
virtual void pushOrSendPacketStart (Packet *packet, cGate *gate, IPassivePacketSink *consumer, bps datarate, int transmissionId)
 
virtual void pushOrSendPacketEnd (Packet *packet, cGate *gate, IPassivePacketSink *consumer, int transmissionId)
 
virtual void pushOrSendPacketProgress (Packet *packet, cGate *gate, IPassivePacketSink *consumer, bps datarate, b position, b extraProcessableLength, int transmissionId)
 
virtual void animatePush (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePushPacket (Packet *packet, cGate *gate) const
 
virtual void animatePushPacketStart (Packet *packet, cGate *gate, bps datarate, long transmissionId) const
 
virtual void animatePushPacketStart (Packet *packet, cGate *gate, bps datarate, const SendOptions &sendOptions) const
 
virtual void animatePushPacketEnd (Packet *packet, cGate *gate, long transmissionId) const
 
virtual void animatePushPacketEnd (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePushPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, long transmissionId) const
 
virtual void animatePushPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, const SendOptions &sendOptions) const
 
virtual void animatePull (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePullPacket (Packet *packet, cGate *gate) const
 
virtual void animatePullPacketStart (Packet *packet, cGate *gate, bps datarate, long transmissionId) const
 
virtual void animatePullPacketStart (Packet *packet, cGate *gate, bps datarate, const SendOptions &sendOptions) const
 
virtual void animatePullPacketEnd (Packet *packet, cGate *gate, long transmissionId) const
 
virtual void animatePullPacketEnd (Packet *packet, cGate *gate, const SendOptions &sendOptions) const
 
virtual void animatePullPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, long transmissionId) const
 
virtual void animatePullPacketProgress (Packet *packet, cGate *gate, bps datarate, b position, b extraProcessableLength, const SendOptions &sendOptions) const
 
virtual void dropPacket (Packet *packet, PacketDropReason reason, int limit=-1)
 
virtual void updateDisplayString () const
 

Protected Attributes

bps datarate = bps(NaN)
 
PacketstreamedPacket = nullptr
 
ClockEventtimer = nullptr
 
- Protected Attributes inherited from inet::queueing::PacketServerBase
cGate * inputGate = nullptr
 
IPassivePacketSourceprovider = nullptr
 
cGate * outputGate = nullptr
 
IPassivePacketSinkconsumer = nullptr
 
- Protected Attributes inherited from inet::queueing::PacketProcessorBase
const char * displayStringTextFormat = nullptr
 
int numProcessedPackets = -1
 
b processedTotalLength = b(-1)
 

Additional Inherited Members

- Protected Types inherited from inet::queueing::PacketProcessorBase
enum  Action { PUSH, PULL }
 

Constructor & Destructor Documentation

◆ ~PreemptingServer()

virtual inet::queueing::PreemptingServer::~PreemptingServer ( )
inlinevirtual

Member Function Documentation

◆ canStartStreaming()

bool inet::queueing::PreemptingServer::canStartStreaming ( ) const
protectedvirtual
33 {
34  return provider->canPullSomePacket(inputGate->getPathStartGate()) && consumer->canPushSomePacket(outputGate->getPathEndGate());
35 }

Referenced by handleCanPullPacketChanged(), and handleCanPushPacketChanged().

◆ endStreaming()

void inet::queueing::PreemptingServer::endStreaming ( )
protectedvirtual
50 {
51  auto packet = provider->pullPacketEnd(inputGate->getPathStartGate());
52  take(packet);
53  delete streamedPacket;
54  streamedPacket = packet;
55  EV_INFO << "Ending streaming packet" << EV_FIELD(packet, *streamedPacket) << EV_ENDL;
56  pushOrSendPacketEnd(streamedPacket, outputGate, consumer, packet->getTransmissionId());
57  streamedPacket = nullptr;
59 }

Referenced by handleCanPullPacketChanged(), and handleMessage().

◆ handleCanPullPacketChanged()

void inet::queueing::PreemptingServer::handleCanPullPacketChanged ( cGate *  gate)
overridevirtual

Notifies about a change in the possibility of pulling some packet from the passive packet source at the given gate.

This method is called, for example, when a new packet is inserted into a queue. It allows the sink to pull a new packet from the queue.

The gate parameter must be a valid gate of this module.

Implements inet::queueing::IActivePacketSink.

69 {
70  Enter_Method("handleCanPullPacketChanged");
71  if (isStreaming()) {
72  endStreaming();
74  }
75  else if (canStartStreaming())
77 }

◆ handleCanPushPacketChanged()

void inet::queueing::PreemptingServer::handleCanPushPacketChanged ( cGate *  gate)
overridevirtual

Notifies about a change in the possibility of pushing some packet into the passive packet sink at the given gate.

This method is called, for example, when a new packet can be inserted into a queue. It allows the source to push a new packet into the queue.

The gate parameter must be a valid gate of this module.

Implements inet::queueing::IActivePacketSource.

62 {
63  Enter_Method("handleCanPushPacketChanged");
64  if (!isStreaming() && canStartStreaming())
66 }

◆ handleMessage()

void inet::queueing::PreemptingServer::handleMessage ( cMessage *  message)
overrideprotectedvirtual
25 {
26  if (message == timer)
27  endStreaming();
28  else
29  PacketServerBase::handleMessage(message);
30 }

◆ handlePushPacketProcessed()

void inet::queueing::PreemptingServer::handlePushPacketProcessed ( Packet packet,
cGate *  gate,
bool  successful 
)
overridevirtual

Notifies about the completion of the packet processing for a packet that was pushed earlier independently whether the packet is passed or streamed.

This method is called, for example, when a previously pushed packet is failed to be processed successfully. It allows the source to retry the operation.

The gate parameter must be a valid gate of this module. The packet must not be nullptr.

Reimplemented from inet::queueing::PacketServerBase.

80 {
81  Enter_Method("handlePushPacketProcessed");
82  if (isStreaming()) {
83  delete streamedPacket;
84  streamedPacket = provider->pullPacketEnd(inputGate->getPathStartGate());
85  take(streamedPacket);
86  EV_INFO << "Ending streaming packet" << EV_FIELD(packet, *streamedPacket) << EV_ENDL;
87  delete streamedPacket;
88  streamedPacket = nullptr;
89  }
90 }

◆ initialize()

void inet::queueing::PreemptingServer::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::queueing::PacketServerBase.

16 {
17  ClockUserModuleMixin::initialize(stage);
18  if (stage == INITSTAGE_LOCAL) {
19  datarate = bps(par("datarate"));
20  timer = new ClockEvent("Timer");
21  }
22 }

◆ isStreaming()

virtual bool inet::queueing::PreemptingServer::isStreaming ( ) const
inlineprotectedvirtual

◆ startStreaming()

void inet::queueing::PreemptingServer::startStreaming ( )
protectedvirtual
38 {
39  auto packet = provider->pullPacketStart(inputGate->getPathStartGate(), datarate);
40  take(packet);
41  EV_INFO << "Starting streaming packet" << EV_FIELD(packet) << EV_ENDL;
42  streamedPacket = packet;
43  pushOrSendPacketStart(streamedPacket->dup(), outputGate, consumer, datarate, packet->getTransmissionId());
47 }

Referenced by handleCanPullPacketChanged(), and handleCanPushPacketChanged().

Member Data Documentation

◆ datarate

bps inet::queueing::PreemptingServer::datarate = bps(NaN)
protected

Referenced by initialize(), and startStreaming().

◆ streamedPacket

Packet* inet::queueing::PreemptingServer::streamedPacket = nullptr
protected

◆ timer

ClockEvent* inet::queueing::PreemptingServer::timer = nullptr
protected

The documentation for this class was generated from the following files:
inet::queueing::PacketServerBase::consumer
IPassivePacketSink * consumer
Definition: PacketServerBase.h:25
inet::units::units::bps
compose< b, pow< s, -1 > > bps
Definition: Units.h:1169
inet::queueing::PreemptingServer::datarate
bps datarate
Definition: PreemptingServer.h:22
inet::ClockUserModuleMixin< PacketServerBase >::scheduleClockEventAfter
virtual void scheduleClockEventAfter(clocktime_t delay, ClockEvent *msg)
Definition: ClockUserModuleMixin.h:65
inet::queueing::PreemptingServer::isStreaming
virtual bool isStreaming() const
Definition: PreemptingServer.h:32
inet::queueing::IPassivePacketSink::canPushSomePacket
virtual bool canPushSomePacket(cGate *gate) const =0
Returns false if the packet sink is full at the given gate and no more packets can be pushed into it ...
inet::queueing::PacketProcessorBase::handlePacketProcessed
virtual void handlePacketProcessed(Packet *packet)
Definition: PacketProcessorBase.cc:34
inet::ClockEvent
cMessage ClockEvent
Definition: contract/ClockEvent.h:18
inet::queueing::PreemptingServer::endStreaming
virtual void endStreaming()
Definition: PreemptingServer.cc:49
inet::queueing::PacketServerBase::provider
IPassivePacketSource * provider
Definition: PacketServerBase.h:22
inet::units::values::s
value< double, units::s > s
Definition: Units.h:1235
inet::Packet::dup
virtual Packet * dup() const override
Definition: Packet.h:171
EV_FIELD
#define EV_FIELD(...)
Definition: INETDefs.h:112
inet::queueing::PreemptingServer::canStartStreaming
virtual bool canStartStreaming() const
Definition: PreemptingServer.cc:32
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
inet::Packet::getTotalLength
b getTotalLength() const
Returns the total packet length ignoring front and back offsets.
Definition: Packet.h:193
inet::queueing::PacketProcessorBase::pushOrSendPacketEnd
virtual void pushOrSendPacketEnd(Packet *packet, cGate *gate, IPassivePacketSink *consumer, int transmissionId)
Definition: PacketProcessorBase.cc:154
inet::ClockUserModuleMixin< PacketServerBase >::cancelAndDeleteClockEvent
virtual void cancelAndDeleteClockEvent(ClockEvent *msg)
Definition: ClockUserModuleMixin.h:67
inet::queueing::PacketProcessorBase::updateDisplayString
virtual void updateDisplayString() const
Definition: PacketProcessorBase.cc:399
inet::queueing::PreemptingServer::streamedPacket
Packet * streamedPacket
Definition: PreemptingServer.h:24
inet::queueing::PreemptingServer::startStreaming
virtual void startStreaming()
Definition: PreemptingServer.cc:37
Enter_Method
#define Enter_Method(...)
Definition: SelfDoc.h:71
inet::queueing::IPassivePacketSource::pullPacketEnd
virtual Packet * pullPacketEnd(cGate *gate)=0
Ends pulling the packet from the packet source at the given gate.
inet::queueing::PacketServerBase::outputGate
cGate * outputGate
Definition: PacketServerBase.h:24
inet::queueing::PacketProcessorBase::pushOrSendPacketStart
virtual void pushOrSendPacketStart(Packet *packet, cGate *gate, IPassivePacketSink *consumer, bps datarate, int transmissionId)
Definition: PacketProcessorBase.cc:136
inet::queueing::IPassivePacketSource::pullPacketStart
virtual Packet * pullPacketStart(cGate *gate, bps datarate)=0
Starts pulling the packet from the packet source at the given gate.
inet::queueing::PreemptingServer::timer
ClockEvent * timer
Definition: PreemptingServer.h:26
inet::queueing::IPassivePacketSource::canPullSomePacket
virtual bool canPullSomePacket(cGate *gate) const =0
Returns false if the packet source is empty at the given gate and no more packets can be pulled from ...
inet::ClockUserModuleMixin< PacketServerBase >::cancelClockEvent
virtual cMessage * cancelClockEvent(ClockEvent *msg)
Definition: ClockUserModuleMixin.h:66
EV_ENDL
#define EV_ENDL
Definition: INETDefs.h:114
inet::queueing::PacketServerBase::inputGate
cGate * inputGate
Definition: PacketServerBase.h:21