Skip to content

Commit

Permalink
Make event translators obsolete
Browse files Browse the repository at this point in the history
  • Loading branch information
ocoanet committed Aug 31, 2019
1 parent d2b52c6 commit 38f50b0
Show file tree
Hide file tree
Showing 19 changed files with 89 additions and 353 deletions.
106 changes: 0 additions & 106 deletions src/Disruptor.PerfTests/Translator/OneToOneTranslatorThroughputTest.cs

This file was deleted.

99 changes: 0 additions & 99 deletions src/Disruptor.Tests/BatchingTest.cs

This file was deleted.

15 changes: 4 additions & 11 deletions src/Disruptor.Tests/BatchingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,13 @@ public void ShouldBatch()

var buffer = d.Start();

IEventTranslator<LongEvent> translator = new EventTranslator<LongEvent>();

const int eventCount = 10000;
for (var i = 0; i < eventCount; i++)
{
buffer.PublishEvent(translator);
using (var scope = buffer.PublishEvent())
{
scope.Event().Value = scope.Sequence;
}
}

while (Volatile.Read(ref handler1.Processed) != eventCount - 1 ||
Expand All @@ -88,13 +89,5 @@ public void ShouldBatch()
Assert.That(handler2.PublishedValue, Is.EqualTo((long)eventCount - 1));
Assert.That(handler2.EventCount, Is.EqualTo((long)eventCount / 2));
}

private class EventTranslator<T> : IEventTranslator<LongEvent>
{
public void TranslateTo(LongEvent eventData, long sequence)
{
eventData.Value = sequence;
}
}
}
}
3 changes: 3 additions & 0 deletions src/Disruptor.Tests/EventPublisherTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
using System;
using Disruptor.Tests.Support;
using NUnit.Framework;

#pragma warning disable 618

namespace Disruptor.Tests
{
[TestFixture]
Expand Down
84 changes: 0 additions & 84 deletions src/Disruptor.Tests/Example/MutliProducerWithTranslator.cs

This file was deleted.

2 changes: 2 additions & 0 deletions src/Disruptor.Tests/RingBufferTests.Obsolete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using NUnit.Framework;
using static Disruptor.Tests.RingBufferEqualsConstraint;

#pragma warning disable 618

namespace Disruptor.Tests
{
partial class RingBufferTests
Expand Down
20 changes: 4 additions & 16 deletions src/Disruptor.Tests/ShutdownOnFatalExceptionTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,16 @@ public void ShouldShutdownGracefulEvenWithFatalExceptionHandler()
{
var bytes = new byte[32];
_random.NextBytes(bytes);
_disruptor.PublishEvent(new ByteArrayTranslator(bytes));
using (var scope = _disruptor.PublishEvent())
{
bytes.CopyTo(scope.Event(), 0);
}
}
});

Assert.IsTrue(task.Wait(1000));
}

public class ByteArrayTranslator : IEventTranslator<byte[]>
{
private readonly byte[] _bytes;

public ByteArrayTranslator(byte[] bytes)
{
_bytes = bytes;
}

public void TranslateTo(byte[] eventData, long sequence)
{
_bytes.CopyTo(eventData, 0);
}
}

[TearDown]
public void Teardown()
{
Expand Down
19 changes: 0 additions & 19 deletions src/Disruptor.Tests/Support/ActionEventTranslator.cs

This file was deleted.

Loading

0 comments on commit 38f50b0

Please sign in to comment.