public HashedWheelScheduler(ThreadFactory threadFactory) { executorService = new HashedWheelTimer(threadFactory); }
@Override public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) { try { return timer.newTimeout(task, delay, unit); } catch (IllegalStateException e) { // timer is shutdown return dummyTimeout; } }
@Override public void shutdown() { executorService.stop(); }
public HeartbeatManager() { this.timeouts = new ConcurrentHashMap<>(); this.timer = new HashedWheelTimer(new NamedThreadFactory("qmq-heartbeat")); this.timer.start(); }
wheel = createWheel(ticksPerWheel); mask = wheel.length - 1; reportTooManyInstances();
/** * Function called when the activator starts just after some * initializations are done by the * ComponentActivatorAbstractBase. * */ @Override public void init() { openDoveGC = new OpenDoveGC(); scheduler = new HashedWheelTimer(1000, TimeUnit.MILLISECONDS); openDoveGC.setTimer(scheduler); scheduler.newTimeout(openDoveGC, 5000, TimeUnit.MILLISECONDS); scheduler.start(); }
@Override public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) { if (task == null) { throw new NullPointerException("task"); } if (unit == null) { throw new NullPointerException("unit"); } long pendingTimeoutsCount = pendingTimeouts.incrementAndGet(); if (maxPendingTimeouts > 0 && pendingTimeoutsCount > maxPendingTimeouts) { pendingTimeouts.decrementAndGet(); throw new RejectedExecutionException("Number of pending timeouts (" + pendingTimeoutsCount + ") is greater than or equal to maximum allowed pending " + "timeouts (" + maxPendingTimeouts + ")"); } start(); // Add the timeout to the timeout queue which will be processed on the next tick. // During processing all the queued HashedWheelTimeouts will be added to the correct HashedWheelBucket. long deadline = System.nanoTime() + unit.toNanos(delay) - startTime; // Guard against overflow. if (delay > 0 && deadline < 0) { deadline = Long.MAX_VALUE; } HashedWheelTimeout timeout = new HashedWheelTimeout(this, task, deadline); timeouts.add(timeout); return timeout; }
@Override public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) { final long currentTime = System.currentTimeMillis(); if (task == null) { throw new NullPointerException("task"); } if (unit == null) { throw new NullPointerException("unit"); } if (!workerThread.isAlive()) { start(); } delay = unit.toMillis(delay); HashedWheelTimeout timeout = new HashedWheelTimeout(task, currentTime + delay); scheduleTimeout(timeout, delay); return timeout; }
wheel = createWheel(ticksPerWheel); iterators = createIterators(wheel); mask = wheel.length - 1;
private Timer newNettyTimer(AsyncHttpClientConfig config) { ThreadFactory threadFactory = config.getThreadFactory() != null ? config.getThreadFactory() : new DefaultThreadFactory(config.getThreadPoolName() + "-timer"); HashedWheelTimer timer = new HashedWheelTimer(threadFactory); timer.start(); return timer; }
public PullMessageProcessor(final DynamicConfig config, final ActorSystem actorSystem, final MessageStoreWrapper messageStoreWrapper, final SubscriberStatusChecker subscriberStatusChecker) { this.config = config; this.actorSystem = actorSystem; this.subscriberStatusChecker = subscriberStatusChecker; this.pullMessageWorker = new PullMessageWorker(messageStoreWrapper, actorSystem); this.timer.start(); }
wheel = createWheel(ticksPerWheel); mask = wheel.length - 1; reportTooManyInstances();
public HashedWheelTimeoutScheduler(ThreadFactory threadFactory) { executorService = new HashedWheelTimer(threadFactory); }
private Timer newNettyTimer() { HashedWheelTimer timer = new HashedWheelTimer(); timer.start(); return timer; }
@Override public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) { try { return timer.newTimeout(task, delay, unit); } catch (IllegalStateException e) { // timer is shutdown return dummyTimeout; } }
@Override public void shutdown() { executorService.stop(); }
@Override public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) { if (task == null) { throw new NullPointerException("task"); } if (unit == null) { throw new NullPointerException("unit"); } long pendingTimeoutsCount = pendingTimeouts.incrementAndGet(); if (maxPendingTimeouts > 0 && pendingTimeoutsCount > maxPendingTimeouts) { pendingTimeouts.decrementAndGet(); throw new RejectedExecutionException("Number of pending timeouts (" + pendingTimeoutsCount + ") is greater than or equal to maximum allowed pending " + "timeouts (" + maxPendingTimeouts + ")"); } start(); // Add the timeout to the timeout queue which will be processed on the next tick. // During processing all the queued HashedWheelTimeouts will be added to the correct HashedWheelBucket. long deadline = System.nanoTime() + unit.toNanos(delay) - startTime; // Guard against overflow. if (delay > 0 && deadline < 0) { deadline = Long.MAX_VALUE; } HashedWheelTimeout timeout = new HashedWheelTimeout(this, task, deadline); timeouts.add(timeout); return timeout; }
wheel = createWheel(ticksPerWheel); mask = wheel.length - 1; reportTooManyInstances();
public HashedWheelTimeoutScheduler() { executorService = new HashedWheelTimer(); }
private Timer newNettyTimer() { HashedWheelTimer timer = new HashedWheelTimer(); timer.start(); return timer; }