Skip to content

Commit

Permalink
Adds a new convenience constructor to SleepingIdleStrategy.
Browse files Browse the repository at this point in the history
The new constructor accepts a TimeUnit.
  • Loading branch information
pveentjer committed Jan 14, 2025
1 parent 5c65251 commit 957c11b
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.agrona.concurrent;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.LockSupport;

/**
Expand Down Expand Up @@ -54,6 +55,17 @@ public SleepingIdleStrategy(final long sleepPeriodNs)
this.sleepPeriodNs = sleepPeriodNs;
}

/**
* Constructed a new strategy that will sleep for a given period when idle.
*
* @param sleepPeriod the period for which the strategy will sleep when work count is 0.
* @param timeUnit the timeunit of the sleepPeriod.
*/
public SleepingIdleStrategy(final long sleepPeriod, final TimeUnit timeUnit)
{
this(timeUnit.toNanos(sleepPeriod));
}

/**
* {@inheritDoc}
*/
Expand Down

0 comments on commit 957c11b

Please sign in to comment.