Example #1
0
        // Note: queue should already be locked.
        void Start_parsing_job(message_envelope <WaypointsType> rv)
        {
            var decoder_tuple = rv.pending_decoders.Peek();

            rv.decoder = decoder_tuple.Item2;
            Task.Factory.StartNew(() => {
                if (stopped == true)
                {
                    return;
                }
                string Error = null;
                rwl.EnterReadLock();
                try {
                    rv.decoder();
                } catch (Exception e) {
                    Error = e.Message;
                } finally {
                    rwl.ExitReadLock();
                    lock (queue) {
                        Debug.Assert(rv.parsing_status == (uint)message_envelope <WaypointsType> .parsing_status_enum.in_progress);
                        if (Error == null)
                        {
                            Debug.Assert(rv.pending_decoders.Count != 0);
                            rv.pending_decoders.Dequeue();
                            rv.parsing_status = (uint)message_envelope <WaypointsType> .parsing_status_enum.end;
                        }
                        else
                        {
                            AddToExceptionText(Error);
                        }
                        Monitor.PulseAll(queue);
                    }
                }
            });
        }
Example #2
0
 release()
 {
     if (last_rv != null)
     {
         lock (consumer.queue) {
             consumer.release(last_rv);
             last_rv = null;
         }
     }
 }
Example #3
0
 release(message_envelope <WaypointsType> rv)
 {
     Debug.Assert(rv != null);
     Debug.Assert(rv.parsing_status == (uint)message_envelope <WaypointsType> .parsing_status_enum.end);
     if (rv.pending_decoders.Count != 0)
     {
         Debug.Assert(queue.Count != 0);
         rv.parsing_status = (uint)message_envelope <WaypointsType> .parsing_status_enum.in_progress;
         Start_parsing_job(rv);
     }
     else
     {
         rv.parsing_status = (uint)message_envelope <WaypointsType> .parsing_status_enum.begin;
     }
 }//```
Example #4
0
 next(int timeout_ms = Timeout.Infinite)
 {
     lock (consumer.queue) {
         Log_text          = consumer.Log_text;
         consumer.Log_text = null;
         if (last_rv != null)
         {
             consumer.release(last_rv);
         }
         last_rv = consumer.dequeue(timeout_ms);
         // Todo -- later more elegance.
         if (consumer.Exception_text != null)
         {
             throw new Exception(consumer.Exception_text);
         }
         else if (publishing_exception.Exception_text != null)
         {
             lock (publishing_exception)
                 throw new Exception(publishing_exception.Exception_text);
         }
         return(last_rv);
     }
 }