Exemple #1
0
 void StartNewValueFile()
 {
     lock (_startNewValueFileLocker)
     {
         QuickFinishCompaction();
         var fileInfo = new FilePureValues(AllocNewFileGeneration());
         if (_cacheValueWriter != null)
         {
             lock (_cacheValueWriter)
             {
                 _cacheValueFile.HardFlush();
                 SetNewValueFile();
             }
         }
         else
         {
             SetNewValueFile();
         }
         fileInfo.WriteHeader(_cacheValueWriter);
         _fileInfos.TryAdd(_cacheValueFileId, fileInfo);
         _compactionCts  = new CancellationTokenSource();
         _compactionTask = Task.Factory.StartNew(CompactionCore, _compactionCts.Token,
                                                 TaskCreationOptions.LongRunning, TaskScheduler.Default);
     }
 }
Exemple #2
0
 void FlushFiles()
 {
     if (_pureValueFileWriter != null)
     {
         _pureValueFileWriter.FlushBuffer();
         _pureValueFile.HardFlush();
     }
     if (_hashIndexWriter != null)
     {
         _hashIndexWriter.FlushBuffer();
         _hashIndexFile.HardFlush();
     }
 }
Exemple #3
0
 public void Dispose()
 {
     _compactorScheduler?.RemoveCompactAction(_compactFunc);
     lock (_writeLock)
     {
         if (_writingTransaction != null)
         {
             throw new BTDBException("Cannot dispose KeyValueDB when writting transaction still running");
         }
         while (_writeWaitingQueue.Count > 0)
         {
             _writeWaitingQueue.Dequeue().TrySetCanceled();
         }
     }
     if (_writerWithTransactionLog != null)
     {
         _writerWithTransactionLog.WriteUInt8((byte)KVCommandType.TemporaryEndOfFile);
         _writerWithTransactionLog.FlushBuffer();
         _fileWithTransactionLog.HardFlush();
         _fileWithTransactionLog.Truncate();
     }
 }