protected void StartQueueProcessing() {
/*
* Simulate packet loss
*/
Random r = new Random();
try {
bool timedout;
while( 1 == _is_started ) {
FQEntry ent = (FQEntry)_queue.Dequeue(-1, out timedout);
if( r.NextDouble() > _ploss_prob ) {
//Stop in this case
if( ent.P == null ) { return; }
FunctionEdge fe = ent.Edge;
BU.MemBlock data_to_send = ent.P as BU.MemBlock;
if( data_to_send == null ) {
data_to_send = BU.MemBlock.Copy(ent.P);
}
try {
fe.ReceivedPacketEvent( data_to_send );
}
catch(EdgeClosedException) {
//The edge may have closed, just ignore it
}
}
}
}
catch(InvalidOperationException) {
// The queue has been closed
}
}