public void Dispose() { Stop(); _sem.Dispose(); _df.Dispose(); _eh.Dispose(); }
public void Dispose() { _df.Dispose(); //foreach (var buffer in _buffers) //{ // buffer.Dispose(); //} }
public void CouldOpenSparse() { var path = TestUtils.GetPath(); var df = new DirectFile(Path.Combine(path, "test.file"), 64L * 1024 * 1024 * 1024, true, FileOptions.WriteThrough, sparse: true); Unsafe.InitBlockUnaligned(df.DirectBuffer.Data, 0, 1024); df.Dispose(); }
public void OpenHugeDirectFile() { var path = TestUtils.GetPath(); var filePath = Path.Combine(path, "test.tmp"); var df = new DirectFile(filePath, 50 * 1024 * 1024 * 1024L, true); var span = df.Buffer.Span; span[1] = 1; df.Dispose(); }
public void CouldWriteToWriteThroughFile() { var path = TestUtils.GetPath(); var df = new DirectFile(Path.Combine(path, "test.file"), 1024 * 1024, true, FileOptions.WriteThrough); df.DirectBuffer.Write(0, 123L); var bytes = new byte[] { 123 }; df._va.WriteArray(0, bytes, 0, 1); var ums = df._mmf.CreateViewStream(0, 1024 * 1024); ums.Write(bytes, 0, 1); ums.Dispose(); df.Flush(true); df.Dispose(); }
public void CouldReadUnallocatedSparse() { var path = TestUtils.GetPath(); var df = new DirectFile(Path.Combine(path, "test.file"), 1L * 1024 * 1024, true, FileOptions.WriteThrough, sparse: true); var sum = 0; for (long i = 0; i < df.Length; i++) { sum += unchecked (df.Buffer[i]); // Console.WriteLine(df.Buffer[i]); } Assert.AreEqual(0, sum); df.Dispose(); }
public unsafe void CouldCatchErrorWhileWritingPastBoundary() { // This doesn;t throw unless size is 4096 vs 12 // Could not make any assumptions that it is safe to write past boundary // with try..catch. Even byte[] allows it and we probably corrupt // .NETs memory next to it. var bytes = new byte[12]; var fb = new FixedBuffer(bytes); fixed(byte *ptr = &bytes[10]) { *(long *)(ptr) = long.MaxValue; } var df = new DirectFile("../CouldCatchErrorWhileWritingPastBoundary", 12); *(long *)(df.Buffer.Data + 10) = long.MaxValue; df.Dispose(); var df2 = new DirectFile("../CouldCatchErrorWhileWritingPastBoundary", 12); Assert.AreEqual(long.MaxValue, *(long *)(df2.Buffer.Data + 10)); }
public void Dispose() { _df.Dispose(); }