예제 #1
0
        internal AsyncQueueWithReliableSending(AsyncReliableQueueWrapperConfiguration config, ILoggingEventWriter logger)
            : base(1, config.MaxQueueSize, "AsyncQueueWithReliableSending for logger", true)
        {
            Contract.Requires(config != null);
            Contract.Requires(logger != null);

            _logger = logger;

            // конфиги для обработки переполнения очереди
            _isOverflowed    = IS_NOT_OVERFLOWED;
            _borderOverflow  = Convert.ToInt32(config.MaxQueueSize * 0.5);
            _isDiscardExcess = config.IsDiscardExcess;

            string newFolderForTemporaryStore = TemporaryStoreLockFile.FindNotLockedDirectory(config.FolderForTemporaryStore, out _tempStoreLock);

            _reader      = new TemporaryStoreReader(newFolderForTemporaryStore);
            _writer      = new TemporaryStoreWriter(newFolderForTemporaryStore, config.MaxFileSize);
            _tokenSource = new CancellationTokenSource();

            _readerThread = new Thread(new ParameterizedThreadStart(TemporaryReaderLoop));
            _readerThread.IsBackground = true;
            _readerThread.Name         = "AsyncQueueWithReliableSending (reader loop) for logger";

            _readerThread.Start(_tokenSource.Token);
            Start();
        }
예제 #2
0
        internal ReliableWrapper(ReliableWrapperConfiguration config, ILoggingEventWriter logger)
        {
            Contract.Requires(config != null);
            Contract.Requires(logger != null);

            _logger = logger;

            string newFolderForTemporaryStore = TemporaryStoreLockFile.FindNotLockedDirectory(config.FolderForTemporaryStore, out _tempStoreLock);

            _reader      = new TemporaryStoreReader(newFolderForTemporaryStore);
            _writer      = new TemporaryStoreWriter(newFolderForTemporaryStore, config.MaxFileSize);
            _tokenSource = new CancellationTokenSource();

            _readerThread = new Thread(new ParameterizedThreadStart(TemporaryReaderLoop));
            _readerThread.IsBackground = true;
            _readerThread.Name         = "AsyncQueueWithReliableSending (reader loop) for logger";

            _readerThread.Start(_tokenSource.Token);
        }