Codota Logo
Timers.runAfter
Code IndexAdd Codota to your IDE (free)

How to use
runAfter
method
in
io.baratine.timer.Timers

Best Java code snippets using io.baratine.timer.Timers.runAfter (Showing top 8 results out of 315)

  • Add the Codota plugin to your IDE and get smart completions
private void myMethod () {
ScheduledThreadPoolExecutor s =
  • Codota Iconnew ScheduledThreadPoolExecutor(corePoolSize)
  • Codota IconThreadFactory threadFactory;new ScheduledThreadPoolExecutor(corePoolSize, threadFactory)
  • Codota IconString str;new ScheduledThreadPoolExecutor(1, new ThreadFactoryBuilder().setNameFormat(str).build())
  • Smart code suggestions by Codota
}
origin: baratine/baratine

 @Override
 public void accept(Cancel handle)
 {
  try {
   sendHeartbeats();
  } finally {
   if (_lifecycle.isActive()) {
    _timer.runAfter(_heartbeatTask, _heartbeatTimeout, TimeUnit.MILLISECONDS, Result.ignore());
   }
  }
 }
}
origin: baratine/baratine

private void onSubscribeFail(Throwable e, long timeout)
{
 log.finer(e.toString());
 log.log(Level.FINEST, e.toString(), e);
 
 ServicesAmp  manager = ServicesAmp.current();
 
 Timers timer = manager.service("timer:///").as(Timers.class);
 
 timer.runAfter(h->resubscribe(timeout), timeout, TimeUnit.SECONDS, 
         Result.ignore());
}

origin: baratine/baratine

@Override
public void afterBatch(StubAmp stub)
{
 if (isSaveRequired()
   && _serviceSelf != null
   && _isCheckpointStarted.compareAndSet(false, true)) {
  if (_journalDelay > 0) {
   _timerService.runAfter(_startSaveRef,
               _journalDelay, TimeUnit.MILLISECONDS, 
               Result.ignore());
  }
  else {
   startSave();
  }
 }
}

origin: baratine/baratine

@OnInit
public void init()
{
 timers.runAfter(this::fire, 2, TimeUnit.SECONDS, Result.ignore());
}
origin: baratine/baratine

/**
 * Join completion
 */
private void onJoinComplete(Integer count,
              Result<Boolean> result)
{
 if (count == null) {
  count = 0;
 }
 
 _joinState = _joinState.onJoinComplete(count, this);
 
 updatePodsFromHeartbeat();
 
 waitForHubHeartbeat(count, result);
 if (_joinLifecycle.toActive()) {
  _timer.runAfter(_joinTask, getJoinTimeout(), TimeUnit.MILLISECONDS, Result.ignore());
 }
}

origin: baratine/baratine

 @Override
 public void accept(Cancel handle)
 {
  if (! _joinLifecycle.isActive()) {
   return;
  }
  
  try {
   if (isJoinRequired()) {
    _lastJoinTime = CurrentTime.currentTime();
    
    _joinClient.start(x->updateRack(x), 
             Result.of(count->onJoinComplete(count, Result.ignore())));
   }
  } finally {
   _timer.runAfter(_joinTask, getJoinTimeout(), TimeUnit.MILLISECONDS, Result.ignore());
  }
 }
}
origin: baratine/baratine

@Test
public void test() throws InterruptedException
{
 _timer.runAfter(t -> State.add("\n  timer!"),
         2,
         TimeUnit.SECONDS,
         Result.ignore());
 TestTime.addTime(1, TimeUnit.SECONDS);
 Thread.sleep(100);
 Assert.assertEquals("", State.state());
 TestTime.addTime(2, TimeUnit.SECONDS);
 Thread.sleep(100);
 Assert.assertEquals("\n  timer!", State.state());
}
origin: baratine/baratine

 @Test
 public void test(@Service("timer:") Timers timer) throws InterruptedException
 {
  timer.runAfter(t -> State.add("\n  timer!"),
          2,
          TimeUnit.SECONDS,
          Result.ignore());

  TestTime.addTime(1, TimeUnit.SECONDS);
  Thread.sleep(100);
  Assert.assertEquals("", State.state());

  TestTime.addTime(2, TimeUnit.SECONDS);
  Thread.sleep(100);

  Assert.assertEquals("\n  timer!", State.state());
 }
}
io.baratine.timerTimersrunAfter

Javadoc

Run the task once after the given delay.
 
MyRunnable task = new MyRunnable(); 
// run once 10 seconds from now 
timers.runAfter(task, 10, TimeUnit.SECONDS); 

Popular methods of Timers

  • runEvery
    Run the task periodically after the given delay. MyRunnable task = new MyRunnable(); // run every

Popular in Java

  • Making http requests using okhttp
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • notifyDataSetChanged (ArrayAdapter)
  • compareTo (BigDecimal)
    Compares this BigDecimal with the specified BigDecimal. Two BigDecimal objects that are equal in val
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • ByteBuffer (java.nio)
    A buffer for bytes. A byte buffer can be created in either one of the following ways: * #allocate(i
  • Connection (java.sql)
    A connection represents a link from a Java application to a database. All SQL statements and results
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • ExecutorService (java.util.concurrent)
    An Executor that provides methods to manage termination and methods that can produce a Future for tr
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now