check point
This commit is contained in:
38
framework/Inspectron.Fastbuffer/IsolatedRingbuffer.cs
Normal file
38
framework/Inspectron.Fastbuffer/IsolatedRingbuffer.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Inspectron.Fastbuffer.Interfaces;
|
||||
|
||||
namespace Inspectron.Fastbuffer;
|
||||
|
||||
public class IsolatedRingbuffer: IDisposable
|
||||
{
|
||||
private readonly string _path;
|
||||
private readonly int _bufferSize;
|
||||
private readonly IFilesystem _filesystem;
|
||||
private readonly string _indexPath;
|
||||
private readonly IndexFile _index;
|
||||
|
||||
public const string BufferDirectory = ".rb";
|
||||
public const string IndexFile = "index.idx";
|
||||
|
||||
public IsolatedRingbuffer(string path, int bufferSize, IFilesystem filesystem)
|
||||
{
|
||||
_path = path;
|
||||
_bufferSize = bufferSize;
|
||||
_filesystem = filesystem;
|
||||
|
||||
_indexPath = Path.Combine(_path, BufferDirectory,IndexFile );
|
||||
Directory.CreateDirectory(Path.Combine(_path, BufferDirectory));
|
||||
|
||||
_index = new IndexFile(_indexPath, _bufferSize, _filesystem);
|
||||
|
||||
}
|
||||
|
||||
public void Write(byte[] data, string fileName)
|
||||
{
|
||||
_index.WriteNextArtifact(data, fileName);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_filesystem.Dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user