/// <summary> /// Destroy the shared memory space and temporary scene objects /// </summary> public void Teardown() { if (!IsRunning) { return; } IsRunning = false; AssemblyReloadEvents.beforeAssemblyReload -= OnBeforeAssemblyReload; EditorApplication.update -= OnEditorUpdate; SceneManager.activeSceneChanged -= OnSceneUnloaded; EditorSceneManager.activeSceneChangedInEditMode -= OnSceneUnloaded; // Notify Blender if we're shutting down from the Unity side if (IsConnected) { messages.WriteDisconnect(); OnDisconnectFromBlender(); } else { // Still clear if we're not connected - we might've torn down // the connection uncleanly and have some persisted data to clean up. Clear(); } // Dispose shared memory messages?.Dispose(); messages = null; pixelsProducer?.Dispose(); pixelsProducer = null; }
/// <summary> /// Destroys the audio renderer. /// Makes it useless. /// </summary> private void Destroy() { try { // Remove the event handler if (Application.Current != null) { Utils.UIInvoke(DispatcherPriority.Normal, () => { Application.Current.Exit -= OnApplicationExit; }); } } catch { } if (AudioDevice != null) { AudioDevice.Stop(); AudioDevice.Dispose(); AudioDevice = null; } if (AudioBuffer != null) { AudioBuffer.Dispose(); AudioBuffer = null; } }
/// <summary> /// Destroys the audio renderer. /// Makes it useless. /// </summary> private void Destroy() { try { // Remove the event handler if (Application.Current != null) { MediaElement.InvokeOnUI(() => { Application.Current.Exit -= OnApplicationExit; }); } } catch { } if (AudioDevice != null) { AudioDevice.Stop(); AudioDevice.Dispose(); AudioDevice = null; } if (AudioBuffer != null) { AudioBuffer.Dispose(); AudioBuffer = null; } }
/// <summary> /// Destroys the audio renderer. /// Makes it useless. /// </summary> private void Destroy() { lock (SyncLock) { if (AudioDevice != null) { AudioDevice.Dispose(); AudioDevice = null; } if (AudioBuffer != null) { AudioBuffer.Dispose(); AudioBuffer = null; } if (AudioProcessor == null) { return; } AudioProcessor.Dispose(); AudioProcessor = null; } }
/// <summary> /// Destroy the shared memory space and temporary scene objects /// </summary> public void Teardown() { AssemblyReloadEvents.beforeAssemblyReload -= OnBeforeAssemblyReload; EditorApplication.update -= OnEditorUpdate; // Notify Blender if we're shutting down from the Unity side if (IsConnected) { messages.WriteDisconnect(); OnDisconnectFromBlender(); } else { // Still clear if we're not connected - we might've torn down // the connection uncleanly and have some persisted data to clean up. Clear(); } IsSetup = false; Debug.Log("Tearing down shared memory space"); // Dispose shared memory messages?.Dispose(); messages = null; pixelsProducer?.Dispose(); pixelsProducer = null; }
/// <summary> /// Destroys the audio renderer. /// Makes it useless. /// </summary> private void Destroy() { try { if (Application.Current != null) { Runner.UIInvoke(DispatcherPriority.Send, () => { Application.Current.Exit -= OnApplicationExit; }); } } catch { } if (AudioDevice != null) { AudioDevice.Pause(); AudioDevice.Dispose(); AudioDevice = null; } if (AudioBuffer != null) { AudioBuffer.Dispose(); AudioBuffer = null; } if (AudioProcessor != null) { AudioProcessor.Dispose(); AudioProcessor = null; } }
public void Dispose() { this._sendQueue?.CompleteAdding(); _stopping = true; try { _sender?.Dispose(); } catch { /* ignored*/ } try { _reciever?.Dispose(); } catch { /* ignored*/ } _sender = null; _reciever = null; }
public void Dispose() { outboundQueue?.Clear(); messageProducer?.Dispose(); messageProducer = null; messageConsumer?.Dispose(); messageConsumer = null; }
public void Return_Arrays_To_Pool_On_Dispose() { var pool = new RememberingPool(ArrayPool <byte> .Shared); var sut = new CircularBuffer(pool); sut.WriteStream.Write(new byte[] { 7, 5, 6, 8 }, 0, 4); sut.Dispose(); pool.HasCurrentRentArrays.Should().BeFalse(); }
private void Dispose(bool disposing) { if (!_disposed) { OnDispose(disposing); if (disposing) { CircularBuffer.Dispose(); } _disposed = true; } }
/// <summary> /// Dispose shared memory and shutdown communication to Unity. /// /// Anything from Unity's side would get cleaned up. /// </summary> public void Disconnect() { messages?.WriteDisconnect(); IsConnectedToUnity = false; IsConnectedToSharedMemory = false; messages?.Dispose(); messages = null; pixelsConsumer?.Dispose(); pixelsConsumer = null; }
public void SimpleReadWrite() { var circularBuffer = new CircularBuffer(); var referenceData = new byte[] { 1 }; circularBuffer.Write(referenceData, 0, referenceData.Length); var readData = new byte[10]; Assert.AreEqual(1, circularBuffer.Read(readData, 0, readData.Length)); Assert.AreEqual(referenceData[0], readData[0]); circularBuffer.Dispose(); Assert.AreEqual(0, circularBuffer.Read(readData, 0, readData.Length)); }
/// <summary> /// Destroys the audio renderer. /// Makes it useless. /// </summary> private void Destroy() { if (AudioDevice != null) { AudioDevice.Stop(); AudioDevice.Dispose(); AudioDevice = null; } if (AudioBuffer != null) { AudioBuffer.Dispose(); AudioBuffer = null; } }
/// <summary> /// Destroys the audio renderer. /// Makes it useless. /// </summary> private void Destroy() { lock (SyncLock) { try { if (Application.Current != null) { WindowsPlatform.Instance.Gui?.Invoke(DispatcherPriority.Send, () => { Application.Current.Exit -= OnApplicationExit; }); } } catch { // ignored } if (AudioDevice != null) { AudioDevice.Pause(); AudioDevice.Dispose(); AudioDevice = null; } if (AudioBuffer != null) { AudioBuffer.Dispose(); AudioBuffer = null; } if (AudioProcessor != null) { AudioProcessor.Dispose(); AudioProcessor = null; } } }
/// <summary> /// Destroys the audio renderer. /// Makes it useless. /// </summary> private void Destroy() { try { if (Application.Current != null) { Application.Current.Exit -= OnApplicationExit; } } catch { } if (AudioDevice != null) { AudioDevice.Stop(); AudioDevice.Dispose(); AudioDevice = null; } if (AudioBuffer != null) { AudioBuffer.Dispose(); AudioBuffer = null; } }
public override void Dispose() { frameInfoBuffer.Dispose(); }
/// <summary/> public void Dispose() { _assembler?.Dispose(); _privateBuffer?.Dispose(); _circularBuffer?.Dispose(); }
/* Overrides */ /// <summary/> public void Dispose() { _circularBuffer?.Dispose(); _shellCode?.Dispose(); }
/// <inheritdoc/> public void Dispose() { _circularBuffer?.Dispose(); ShellCode?.Dispose(); GC.SuppressFinalize(this); }
public void Dispose() { _circularBuffer?.Dispose(); }
/// <inheritdoc /> protected override void OnDispose(bool disposing) { _circularBuffer.Dispose(); }
public void UnsafePeekTest_With_Overflow() { Random rnd = new Random(1337); byte[] buffer = new byte[9]; rnd.NextBytes(buffer); CircularBuffer cb = new CircularBuffer(16); byte[] dummy = new byte[100]; fixed(byte *src = dummy) { Assert.AreEqual(0, cb.Peek(src, 78, 0)); } cb.Write(buffer, 0, buffer.Length); fixed(byte *src = dummy) { Assert.AreEqual(buffer.Length, cb.Peek(src, 78, 0)); } cb.Dispose(); cb = new CircularBuffer(16); cb.Write(buffer, 0, buffer.Length); cb.Write(buffer, 0, buffer.Length); Assert.AreEqual(cb.Count, 16); byte[] readBuffer2 = new byte[9]; fixed(byte *src = readBuffer2) { Assert.AreEqual(7, cb.Peek(src, readBuffer2.Length, 9)); } Assert.AreEqual(cb.Count, 16); Assert.IsFalse(cb.IsEmpty); Assert.IsTrue(readBuffer2.Take(7).SequenceEqual(buffer.Take(7))); cb.Dispose(); cb = new CircularBuffer(16); cb.Write(buffer, 0, buffer.Length); byte[] readBuffer4 = new byte[9]; fixed(byte *src = readBuffer4) { Assert.AreEqual(9, cb.Read(src, readBuffer4.Length, 0)); } Assert.AreEqual(0, cb.Count); Assert.IsTrue(cb.IsEmpty); cb.Write(buffer, 0, buffer.Length); fixed(byte *src = readBuffer4) { Assert.AreEqual(9, cb.Peek(src, readBuffer4.Length, 0)); } Assert.AreEqual(cb.Count, 9); Assert.IsFalse(cb.IsEmpty); cb.Dispose(); cb = new CircularBuffer(16); cb.Write(buffer, 0, buffer.Length); fixed(byte *src = readBuffer4) { Assert.AreEqual(9, cb.Read(src, readBuffer4.Length, 0)); } Assert.AreEqual(0, cb.Count); Assert.IsTrue(cb.IsEmpty); cb.Write(buffer, 0, buffer.Length); fixed(byte *src = readBuffer4) { Assert.AreEqual(1, cb.Peek(src, 1, 8)); } Assert.AreEqual(9, cb.Count); Assert.IsFalse(cb.IsEmpty); Assert.IsTrue(readBuffer4.Take(1).SequenceEqual(buffer.Skip(8).Take(1))); }
public void SafeReadTest_With_Overflow() { Random rnd = new Random(1337); byte[] buffer = new byte[9]; rnd.NextBytes(buffer); CircularBuffer cb = new CircularBuffer(16); byte[] dummy = new byte[100]; Assert.AreEqual(0, cb.Read(dummy, 0, 78, 0)); cb.Write(buffer, 0, buffer.Length); Assert.AreEqual(buffer.Length, cb.Read(dummy, 0, 78, 0)); cb.Dispose(); cb = new CircularBuffer(16); cb.Write(buffer, 0, buffer.Length); cb.Write(buffer, 0, buffer.Length); Assert.AreEqual(cb.Count, 16); byte[] readBuffer2 = new byte[9]; Assert.AreEqual(readBuffer2.Length, cb.Read(readBuffer2, 0, readBuffer2.Length, 0)); Assert.AreEqual(cb.Count, 16 - 9); Assert.IsFalse(cb.IsEmpty); Assert.IsTrue(readBuffer2.Take(9).SequenceEqual(buffer)); cb.Dispose(); cb = new CircularBuffer(16); cb.Write(buffer, 0, buffer.Length); byte[] readBuffer4 = new byte[9]; Assert.AreEqual(9, cb.Read(readBuffer4, 0, readBuffer4.Length, 0)); Assert.AreEqual(cb.Count, 0); Assert.IsTrue(cb.IsEmpty); cb.Write(buffer, 0, buffer.Length); Assert.AreEqual(9, cb.Read(readBuffer4, 0, readBuffer4.Length, 0)); Assert.AreEqual(cb.Count, 0); Assert.IsTrue(cb.IsEmpty); cb.Dispose(); cb = new CircularBuffer(16); cb.Write(buffer, 0, buffer.Length); Assert.AreEqual(9, cb.Read(readBuffer4, 0, readBuffer4.Length, 0)); Assert.AreEqual(cb.Count, 0); Assert.IsTrue(cb.IsEmpty); cb.Write(buffer, 0, buffer.Length); Assert.AreEqual(1, cb.Read(readBuffer4, 0, 1, 8)); Assert.AreEqual(cb.Count, 0); Assert.IsTrue(cb.IsEmpty); Assert.IsTrue(readBuffer4.Take(1).SequenceEqual(buffer.Skip(8).Take(1))); }
public void Dispose() { _circularBuffer?.Dispose(); _circularBuffer = null; }