History

1) Removed warnings occuring from new code additions. 2) More reorganization and code clean-up. 3) Globally applied static Endian order classes where possible.

ritchiecarroll committed 12 years ago

Commit 51177ba1 parent 0465735147 files · +968 −906Browse files

Showing the changes to Source/Libraries/GSF.Core/Parsing/MultiSourceFrameImageParserBase.cs (1 of 147 files). Show all

Unified · Split

Source/Libraries/GSF.Core/Parsing/MultiSourceFrameImageParserBase.cs+18−25
@@ -37,7 +37,6 @@ using System; · 36 unmodified lines
3737 using System.Collections.Concurrent;
3838 using System.Collections.Generic;
3939 using System.ComponentModel;
40−using System.Threading;
4140 using GSF.Collections;
4241
4342 namespace GSF.Parsing
@@ -54,7 +53,7 @@ namespace GSF.Parsing · 10 unmodified lines
5453 /// This class is more specific than the <see cref="BinaryImageParserBase"/> in that it can automate the parsing of a
5554 /// particular protocol that is formatted as a series of frames that have a common method of identification.
5655 /// Automation of type creation occurs by loading implementations of common types that implement the
57− /// <see cref="ISupportSourceIdentifiableFrameImage{TSourceIdentifier,TTypeIdentifier}"/> interface. The common method of
56+ /// <see cref="ISupportSourceIdentifiableFrameImage{TSourceIdentifier, TTypeIdentifier}"/> interface. The common method of
5857 /// identification is handled by creating a class derived from the <see cref="ICommonHeader{TTypeIdentifier}"/> which primarily
5958 /// includes a TypeID property, but also should include any state information needed to parse a particular frame if necessary.
6059 /// Derived classes override the <see cref="FrameImageParserBase{TTypeIdentifier, TOutputType}.ParseCommonHeader"/>
@@ -334,8 +333,10 @@ namespace GSF.Parsing · 273 unmodified lines
334333 // Copy buffer data for processing (destination buffer pre-allocated from buffer pool)
335334 Buffer.BlockCopy(buffer, offset, identifiableBuffer.Buffer, 0, count);
336335
337− // Add buffer to the queue for parsing
338− m_bufferQueue.Enqueue(new SourceIdentifiableBuffer[] { identifiableBuffer });
336+ // Add buffer to the queue for parsing. Note that buffer is queued for parsing instead
337+ // of handling parse on this thread - this has become necessary to reduce UDP data loss
338+ // that can happen in-process when system has UDP buffers building up for processing.
339+ m_bufferQueue.Enqueue(new[] { identifiableBuffer });
339340 }
340341 }
341342 catch
@@ -398,7 +399,7 @@ namespace GSF.Parsing · 56 unmodified lines
398399 throw new NotImplementedException("This method should not be called directly, call the Parse(TSourceIdentifier,byte[],int,int) method to queue data for parsing instead.");
399400 }
400401
401− // This method is used by the internal <see cref="ProcessQueue{T}"/> to process all queued data buffers.
402+ // This method is used to process all queued data buffers.
402403 private void ParseQueuedBuffers(IList<SourceIdentifiableBuffer> buffers)
403404 {
404405 if (Enabled)
@@ -427,6 +428,16 @@ namespace GSF.Parsing · 22 unmodified lines
427428 }
428429 finally
429430 {
431+ // Dispose of source buffers - this returns buffers to pool
432+ if ((object)buffers != null)
433+ {
434+ foreach (SourceIdentifiableBuffer buffer in buffers)
435+ {
436+ if ((object)buffer != null)
437+ buffer.Dispose();
438+ }
439+ }
440+
430441 // If user has attached to SourceDataParsed event, expose list of parsed data per source
431442 if ((object)SourceDataParsed != null)
432443 {
@@ -435,28 +446,10 @@ namespace GSF.Parsing · 2 unmodified lines
435446 OnSourceDataParsed(parsedData.Key, parsedData.Value);
436447 }
437448
438− // Clear parsed data dictionary for next pass
449+ // Clear parsed data dictionary for next pass - note that this does not contend with
450+ // OnDataParsed override since the event called synchronously via base.Write above.
439451 m_parsedSourceData.Clear();
440452 }
441−
442− }
443− }
444−
445− // Dispose of source buffers - no rush
446− ThreadPool.QueueUserWorkItem(DisposeSourceBuffers, buffers);
447− }
448−
449− // Handle disposing of source buffers (this will return items to the reusable object pool)
450− private void DisposeSourceBuffers(object state)
451− {
452− SourceIdentifiableBuffer[] buffers = state as SourceIdentifiableBuffer[];
453−
454− if ((object)buffers != null)
455− {
456− foreach (SourceIdentifiableBuffer buffer in buffers)
457− {
458− if ((object)buffer != null)
459− buffer.Dispose();
460453 }
461454 }
462455 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t