com.hazelcast.util.executor
Class StripedExecutor

java.lang.Object
  extended by com.hazelcast.util.executor.StripedExecutor
All Implemented Interfaces:
Executor

public final class StripedExecutor
extends Object
implements Executor

The StripedExecutor internally uses a stripe of queues and each queue has its own private worker-thread. When a task is 'executed' on the StripedExecutor, the task is checked if it is a StripedRunnable. If it is, the right worker is looked up and the task put in the queue of that worker. If the task is not a StripedRunnable, a random worker is looked up.

If the queue is full and the runnable implements TimeoutRunnable, then a configurable amount of blocking is done on the queue. If the runnable doesn't implement TimeoutRunnable or when the blocking times out, then the task is rejected and a RejectedExecutionException is thrown.


Field Summary
static AtomicLong THREAD_ID_GENERATOR
           
 
Constructor Summary
StripedExecutor(ILogger logger, String threadNamePrefix, ThreadGroup threadGroup, int threadCount, int maximumQueueSize)
           
 
Method Summary
 void execute(Runnable command)
           
 int getWorkQueueSize()
          Returns the total number of tasks pending to be executed.
 boolean isLive()
          Checks if this StripedExecutor is alive (so not shut down).
 void shutdown()
          Shuts down this StripedExecutor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

THREAD_ID_GENERATOR

public static final AtomicLong THREAD_ID_GENERATOR
Constructor Detail

StripedExecutor

public StripedExecutor(ILogger logger,
                       String threadNamePrefix,
                       ThreadGroup threadGroup,
                       int threadCount,
                       int maximumQueueSize)
Method Detail

getWorkQueueSize

public int getWorkQueueSize()
Returns the total number of tasks pending to be executed.

Returns:
total work queue size.

shutdown

public void shutdown()
Shuts down this StripedExecutor.

No checking is done if the StripedExecutor already is shut down, so it should be called only once.

If there is any pending work, it will be thrown away.


isLive

public boolean isLive()
Checks if this StripedExecutor is alive (so not shut down).

Returns:

execute

public void execute(Runnable command)
Specified by:
execute in interface Executor


Copyright © 2015 Hazelcast, Inc.. All Rights Reserved.