4

If you're aiming for KISS at the level of maintenance, this looks like a reasonable solution, although there are some minor details which IMO could be improved. public class UniqueBufferBlock { private readonly BufferBlock<string> _buffer = new BufferBlock<string>(); private readonly HashSet<string> _hashSet = new HashSet<string&...


4

General comments: I would move the timeout and batch sizes into private fields. I don't know what version of c# you are using but you could create a class or if you have the nice tuple support you can just create it like so private readonly (TimeSpan timeout, int buffer) _saveBatchSettings = (TimeSpan.FromSeconds(3), 1000); private readonly (TimeSpan ...


3

class BatchedQueue What's the reason for having this separate class? Is it so that there is only one instance of SlotClassLogger? If that's the case, that sounds like premature optimization to me. class BatchedQueue<T> : BatchedQueue You're not implementing (or exposing in other way) any of the dataflow interfaces. That means this class can't easily ...


3

Note that Endpoints.Contains(endpoint) will never be true, because you create a new IPEndPoint, and it does not implement IEquatable interface. In addition to @mjolka's description why you have a 50% CPU load, I would like to suggest how you can avoid it. Currently you have a central place that manages all sockets in one place. I suggest to do it ...


2

My suggestions Use var. For example in this piece of code List<List<UniqueId>> list_of_list_of_uids = new List<List<UniqueId>>(); is will be much more readable I think the code under is redundant. Because using keyword (when it is compiled into IL code) already contains finally statement with Dispose inside. I am pretty sure that ...


2

I would start with extracting the message formatting logic to a separate method. It will make profiling and performance testing easier. foreach (var item in messages.GetConsumingEnumerable(_cancellationTokenSource.Token)) { formatted = FormatSingleMessage(item); formattedMessages.Add(formatted); } Then you can check the FormatSingleMessage method ...


2

Isn't it possible to rewrite the code to a single pipeline without creating an instance of a nested pipeline for each message? It really seems a hard task because you are putting the pipeline building logic into the transform Method. Create a method to build your pipeline, it is really asking for it! private static PipelineType _pipeline; private static ...


2

It's not surprising that CPU usage is at 50%, it looks like you're busy-waiting. while (Receive) { try { var readyChannels = ... foreach (var channel in readyChannels) { ... } } catch (Exception ex) { ... } } From Wikipedia, In software engineering, busy-waiting or spinning is a ...


2

var batchStockEvents = new BatchBlock<T>(batchSize); I think that batchStockEvents is a weird name for a BatchBlock. It sounds like it's a collection of events, or something like that. new Timer(delegate { batchStockEvents.TriggerBatch(); }); While using delegate this way allows you to ignore the parameter, I think it's cleaner (and shorter) to use ...


2

Looks Good To Me. I was initially confused by this code, so I would want to rename the collection from UniqueStrings to something like UniqueStringBuffer, to make the purpose clear. To me, "buffer" says "I will use this object to hold data temporarily, because the data is consumed at a different rate than it is produced" - which is exactly what you have ...


1

A few comments: var handler = Container.GetInstance<IMessageHandler<TMessage, TReply>>(); You're looking up the IMessageHandler inside the handler block, which means you're looking it up for every message. I'm not that familiar with SimpleInjector, but you may want to memoize this or somehow cache the handler for a given message type. private ...


1

You are starting two Task in ValidateProxiesAsync - one in the method and another in the extension method. Really seems it should be one Task. Also judges is an IEnumerable that you are constantly doing ElementAt. Should either do First and store that value for each call or pass in an IList or Array is that's what it really is if you need to access it ...


1

Just some minor suggestions to add. Double Initialization You're initializing your lists twice. First on declaration, then when you call the function on the next line. Just initialize to the functions. e.g. var uids = GetUids(); var (As Disappointed suggested) This is mostly preference but List<UniqueId> list_of_uids = new List<UniqueId>(); ...


1

You're not afraid of long names which is great. Descriptive long names are definitely better than vague short ones. I think you could probably make the code slightly easier to read though: getterFunction could be valueFactory getterFunctionWaitPeriod ccould be refreshInterval or timeToLive hasRunGetterFunctionFirstTimeForInstanceLock could be ...


Only top voted, non community-wiki answers of a minimum length are eligible