org.codehaus.gpars

groovyx.gpars.scheduler
[Java] Class Scheduler

java.lang.Object
  groovyx.gpars.scheduler.Scheduler
All Implemented Interfaces:
Pool

public final class Scheduler

Prototype of self-regulated thread pooled scheduler

Self regulation happened according to following rules - worker thread, which had nothing to do 10 seconds dies - if no tasks were taken for processing during last 0.5sec new worker starts


Nested Class Summary
private class Scheduler.WatchdogThread

private class Scheduler.WorkerThread

 
Field Summary
private static long POKE_INTERVAL

static java.lang.RuntimeException TERMINATE

private long lastTaskPoke

private java.util.concurrent.BlockingQueue queue

private long schedulerTime

private boolean terminating

private java.util.concurrent.atomic.AtomicInteger threadCount

 
Constructor Summary
Scheduler()

Scheduler(int coreSize)

 
Method Summary
void execute(java.lang.Runnable task)

int getPoolSize()

Retrieves the current thread pool size

java.lang.Runnable loop(java.lang.Runnable operation)

void resetDefaultSize()

void resize(int poolSize)

void shutdown()

private void startNewThread()

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#wait(long, int), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Field Detail

POKE_INTERVAL

private static final long POKE_INTERVAL


TERMINATE

static final java.lang.RuntimeException TERMINATE


lastTaskPoke

private long lastTaskPoke


queue

private final java.util.concurrent.BlockingQueue queue


schedulerTime

private long schedulerTime


terminating

private boolean terminating


threadCount

private final java.util.concurrent.atomic.AtomicInteger threadCount


 
Constructor Detail

Scheduler

public Scheduler()


Scheduler

public Scheduler(int coreSize)


 
Method Detail

execute

@Override
public void execute(java.lang.Runnable task)


getPoolSize

@Override
public int getPoolSize()
Retrieves the current thread pool size
Returns:
The pool size


loop

public java.lang.Runnable loop(java.lang.Runnable operation)


resetDefaultSize

@Override
public void resetDefaultSize()


resize

@Override
public void resize(int poolSize)


shutdown

@Override
@SuppressWarnings({"ObjectAllocationInLoop"})
public void shutdown()


startNewThread

private void startNewThread()


 

Copyright © 2008–2012 Václav Pech. All Rights Reserved.