Skip to content

Commit

Permalink
Impove wait strategy documentation #96.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeb01 committed Mar 6, 2018
1 parent 36f5db3 commit 23d391d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/main/java/com/lmax/disruptor/SleepingWaitStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@

/**
* Sleeping strategy that initially spins, then uses a Thread.yield(), and
* eventually sleep (<code>LockSupport.parkNanos(1)</code>) for the minimum
* eventually sleep (<code>LockSupport.parkNanos(n)</code>) for the minimum
* number of nanos the OS and JVM will allow while the
* {@link com.lmax.disruptor.EventProcessor}s are waiting on a barrier.
* <p>
* This strategy is a good compromise between performance and CPU resource.
* Latency spikes can occur after quiet periods.
* Latency spikes can occur after quiet periods. It will also reduce the impact
* on the producing thread as it will not need signal any conditional variables
* to wake up the event handling thread.
*/
public final class SleepingWaitStrategy implements WaitStrategy
{
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/com/lmax/disruptor/YieldingWaitStrategy.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* Yielding strategy that uses a Thread.yield() for {@link com.lmax.disruptor.EventProcessor}s waiting on a barrier
* after an initially spinning.
* <p>
* This strategy is a good compromise between performance and CPU resource without incurring significant latency spikes.
* This strategy will use 100% CPU, but will more readily give up the CPU than a busy spin strategy if other threads
* require CPU resource.
*/
public final class YieldingWaitStrategy implements WaitStrategy
{
Expand Down

0 comments on commit 23d391d

Please sign in to comment.