public void EnqueueAction(IAction a) {
#if BRUNET_SIMULATOR
SimpleTimer.Enqueue(a, 0, 0);
return;
#else
int queue_size = _packet_queue.Count;
if( queue_size > MAX_QUEUE_LENGTH ) {
/*
* Disconnect actually assumes the _packet_queue is being processed
* if it is not, due to a blocking operation, or deadlock, we could
* still be adding things into the queue. This is here to prevent
* a memory explosion
*/
// throw new Exception(String.Format("Queue is too long: {0}", queue_size));
LogPacketQueue();
}
int count = _packet_queue.Enqueue(a);
_packet_queue_exp_avg = (PACKET_QUEUE_RETAIN * _packet_queue_exp_avg)
+ ((1 - PACKET_QUEUE_RETAIN) * count);
if(_packet_queue_exp_avg > MAX_AVG_QUEUE_LENGTH) {
LogPacketQueue();
if(_disconnect_on_overload) {
Disconnect();
}
}
#endif
}