Skip to content

Commit

Permalink
Remove previously deprecated timeout methods.
Browse files Browse the repository at this point in the history
- Mirror java 7dc21ed203cf958504cc66c9cc0b5937133a48f7
  • Loading branch information
damageboy committed Jul 10, 2013
1 parent 7f35752 commit a67a8aa
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 109 deletions.
42 changes: 0 additions & 42 deletions Disruptor.Tests/SequencerTests.cs
Expand Up @@ -159,48 +159,6 @@ public void ShouldHoldUpPublisherWhenBufferIsFull()
Assert.AreEqual(_sequencer.Cursor, expectedFullSequence + 1L);
}

[Test]
public void ShouldNotTimeoutWhenBufferHasSufficientCapacity()
{
long sequence = _sequencer.Next(TimeSpan.FromSeconds(1L));
Assert.AreEqual(Sequencer.InitialCursorValue + 1L, sequence);
}

[Test]
[ExpectedException(typeof(TimeoutException))]
public void ShouldThrowExceptionDueToTimeoutWhenInsufficientCapacity()
{
long expectedFullSequence = Sequencer.InitialCursorValue + _sequencer.BufferSize;
_sequencer.Claim(expectedFullSequence);
_sequencer.Publish(expectedFullSequence);

_sequencer.Next(TimeSpan.FromSeconds(1));
}

[Test]
public void ShouldNotTimeoutWhenBufferHasSufficientCapacityForBatch()
{
const int batchSize = 3;
BatchDescriptor batchDescriptor = _sequencer.NewBatchDescriptor(batchSize);

batchDescriptor = _sequencer.Next(batchDescriptor, TimeSpan.FromSeconds(1));
Assert.AreEqual(Sequencer.InitialCursorValue + batchSize, batchDescriptor.End);
}

[Test]
[ExpectedException(typeof(TimeoutException))]
public void ShouldThrowExceptionDueToTimeoutWhenInsufficientCapacityForBatch()
{
long expectedFullSequence = Sequencer.InitialCursorValue + _sequencer.BufferSize;
_sequencer.Claim(expectedFullSequence);
_sequencer.Publish(expectedFullSequence);

const int batchSize = 3;
BatchDescriptor batchDescriptor = _sequencer.NewBatchDescriptor(batchSize);

_sequencer.Next(batchDescriptor, TimeSpan.FromSeconds(1));
}

[Test]
[ExpectedException(typeof(InsufficientCapacityException))]
public void ShouldThrowInsufficientCapacityExceptionWhenSequencerIsFull()
Expand Down
15 changes: 0 additions & 15 deletions Disruptor/EventPublisher.cs
Expand Up @@ -30,21 +30,6 @@ public void PublishEvent(Func<T,long,T> translator)
long sequence = _ringBuffer.Next();
TranslateAndPublish(translator, sequence);
}
/// <summary>
/// Publishes an event to the ring buffer. It handles
/// claiming the next sequence, getting the current (uninitialized)
/// event from the ring buffer and publishing the claimed sequence
/// after translation.
/// </summary>
/// <param name="translator">The user specified translation for the event</param>
/// <param name="timeout"></param>
/// <remarks>Obsolete: Timeout based methods are a bad idea, if timeout functionality
/// is required, then it can be implemented on top tryPublishEvent</remarks>
public void PublishEvent(Func<T, long, T> translator, TimeSpan timeout)
{
long sequence = _ringBuffer.Next(timeout);
TranslateAndPublish(translator, sequence);
}
/// </summary>
/// <param name="translator">The user specified translation for the event</param>
/// <param name="capacity">The capacity that should be available before publishing</param>
Expand Down
50 changes: 0 additions & 50 deletions Disruptor/Sequencer.cs
@@ -1,5 +1,4 @@
using System;
using System.Diagnostics;

namespace Disruptor
{
Expand Down Expand Up @@ -129,24 +128,6 @@ public long TryNext(int availableCapacity)
return _claimStrategy.CheckAndIncrement(availableCapacity, 1, _gatingSequences);
}


/// <summary>
/// Claim the next event in sequence for publishing with a timeout.
/// If the timeout occurs the sequence will not be claimed and a <see cref="TimeoutException"/> will be thrown.
///
/// </summary>
/// <param name="timeout">timeout period to wait</param>
/// <returns>the claimed sequence value</returns>
/// <remarks>This method is obsolete, Use <see cref="TryNext"/> to avoid blocking indefinitely. Any timeout behavior
/// should be handled within the calling code.</remarks>
[Obsolete]
public long Next(TimeSpan timeout)
{
WaitForCapacity(1, timeout);

return Next();
}

/// <summary>
/// Claim the next batch of sequence numbers for publishing.
/// </summary>
Expand All @@ -164,24 +145,6 @@ public BatchDescriptor Next(BatchDescriptor batchDescriptor)
return batchDescriptor;
}

/// <summary>
/// Claim the next batch of sequence numbers for publishing with a timeout.
/// If the timeout occurs the sequence will not be claimed and a <see cref="TimeoutException"/> will be thrown.
///
/// </summary>
/// <param name="batchDescriptor">batchDescriptor to be updated for the batch range.</param>
/// <param name="timeout">timeout period to wait</param>
/// <returns>the updated batchDescriptor.</returns>
/// <remarks>This method is obsolete, Use <see cref="TryNext"/> to avoid blocking indefinitely. Any timeout behavior
/// should be handled within the calling code.</remarks>
[Obsolete]
public BatchDescriptor Next(BatchDescriptor batchDescriptor, TimeSpan timeout)
{
WaitForCapacity(batchDescriptor.Size, timeout);

return Next(batchDescriptor);
}

/// <summary>
/// Claim a specific sequence when only one publisher is involved.
/// </summary>
Expand Down Expand Up @@ -235,18 +198,5 @@ private void Publish(long sequence, int batchSize)
_claimStrategy.SerialisePublishing(sequence, _cursor, batchSize);
_waitStrategy.SignalAllWhenBlocking();
}

private void WaitForCapacity(int capacity, TimeSpan timeout)
{
var sw = Stopwatch.StartNew();

while (!_claimStrategy.HasAvailableCapacity(capacity, _gatingSequences))
{
if (sw.Elapsed > timeout)
{
throw _timeoutExceptionInstance;
}
}
}
}
}
4 changes: 2 additions & 2 deletions Version.cs
Expand Up @@ -16,5 +16,5 @@
[assembly: AssemblyCompany("http://github.com/odeheurles/Disruptor-net/network")]
[assembly: AssemblyProduct("Disruptor")]
[assembly: AssemblyCopyright("Copyright © disruptor-net")]
[assembly: AssemblyVersion("2.9.0")]
[assembly: AssemblyFileVersion("2.9.0")]
[assembly: AssemblyVersion("2.10.0")]
[assembly: AssemblyFileVersion("2.10.0")]

0 comments on commit a67a8aa

Please sign in to comment.