示例#1
0
        bool ICombinedSourceSearchResultInternal.Add(IMessage msg)
        {
            if (!messages.Add(msg))
            {
                return(false);                // todo: report OOO message
            }
            sequentialMessagesPositions.Add(lastSequentialPosition);
            var msgLen = msg.EndPosition - msg.Position;

            lastSequentialPosition += msgLen;
            return(true);
        }
示例#2
0
        async Task <SearchResultStatus> Worker(CancellationToken cancellation, Progress.IProgressEventsSink progressSink)
        {
            using (IStringSliceReallocator reallocator = new StringSliceReallocator())
                try
                {
                    bool limitReached = false;
                    await searchWorker.GetMessages(
                        parent.OptionsFilter,
                        (msg) =>
                    {
                        if (!parent.AboutToAddNewMessage())
                        {
                            limitReached = true;
                            return(false);
                        }
                        lock (messagesLock)
                        {
                            if (!messages.Add(msg.Message))
                            {
                                return(true);
                            }
                            msg.Message.SetFilteringResult(msg.FilteringResult.Action);
                            msg.Message.ReallocateTextBuffer(reallocator);
                            Interlocked.Increment(ref hitsCount);
                        }
                        parent.OnResultChanged(this);
                        return(true);
                    },
                        cancellation,
                        progressSink
                        );

                    return(limitReached ? SearchResultStatus.HitLimitReached : SearchResultStatus.Finished);
                }
                catch (OperationCanceledException)
                {
                    return(SearchResultStatus.Cancelled);
                }
        }