当前位置: 首页>>代码示例>>Java>>正文


Java PriorityScheduler类代码示例

本文整理汇总了Java中org.threadly.concurrent.PriorityScheduler的典型用法代码示例。如果您正苦于以下问题:Java PriorityScheduler类的具体用法?Java PriorityScheduler怎么用?Java PriorityScheduler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PriorityScheduler类属于org.threadly.concurrent包,在下文中一共展示了PriorityScheduler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: BaseSC2Client

import org.threadly.concurrent.PriorityScheduler; //导入依赖的package包/类
public BaseSC2Client(PriorityScheduler ps, SocketExecuter se, InetSocketAddress host) throws IOException {
  this.ps = ps;
  this.se = se;
  this.host = host;
  this.client = se.createTCPClient(host.getHostName(), host.getPort());
  this.client.setReader((c)->onRead());
  client.write(WSRequest.getByteBuffer()).addCallback(new FutureCallback<Object>() {

    @Override
    public void handleResult(Object result) {
      log.debug("Sent WebSocket Request:{}", WSRequest);
    }

    @Override
    public void handleFailure(Throwable t) {
      
    }});
}
 
开发者ID:lwahlmeier,项目名称:sc2-java-api,代码行数:19,代码来源:BaseSC2Client.java

示例2: executeIfStillRunning

import org.threadly.concurrent.PriorityScheduler; //导入依赖的package包/类
@Override
public ListenableFuture<?> executeIfStillRunning(ExecutionItem item, boolean forceAsync) {
  // the existence of the scheduler (and possibly limiter) indicate still running
  SubmitterExecutor limiter = this.limiter;
  if (limiter != null && ! item.isChainExecutor()) {
    return limiter.submit(wrapInRunnable(item));
  } else {
    PriorityScheduler scheduler = this.scheduler.get();
    if (scheduler != null) {
      if (forceAsync) {
        ExecuteOnGetFutureTask<?> result = new ExecuteOnGetFutureTask<Void>(wrapInRunnable(item));
        scheduler.execute(result);
        return result;
      } else {
        item.itemReadyForExecution(this);
      }
    }
  }
  return ImmediateResultListenableFuture.NULL_RESULT;
}
 
开发者ID:threadly,项目名称:ambush,代码行数:21,代码来源:ExecutableScript.java

示例3: FakeHTTPStreamingServer

import org.threadly.concurrent.PriorityScheduler; //导入依赖的package包/类
public FakeHTTPStreamingServer(int port, HTTPResponse hr, String sendBack, int kiloToSend, boolean doSSL, boolean chunk) throws IOException {
  this.port = port;
  this.hr = hr;
  this.chunked = chunk;
  kToSend = kiloToSend;
  if(doSSL) {
    doSSLCrap();
  }
  PS = new PriorityScheduler(5);
  SEB = new ThreadedSocketExecuter(PS);
  SEB.start();
  server = new HTTPServer(SEB, "localhost", port, sslCtx);
  server.addHandler(this);
  server.start();
  this.sendBack.add(ByteBuffer.wrap(sendBack.getBytes()));
}
 
开发者ID:threadly,项目名称:litesockets-http,代码行数:17,代码来源:FakeHTTPStreamingServer.java

示例4: start

import org.threadly.concurrent.PriorityScheduler; //导入依赖的package包/类
@Before
public void start() throws IOException {
  PS = new PriorityScheduler(5);
  ntSE = new NoThreadSocketExecuter();
  SE = ntSE;
  SE.start();
  PS.scheduleWithFixedDelay(new Runnable() {
    @Override
    public void run() {
      ntSE.select();
    }}, 10, 10);
  serverFC = new FakeUDPServerClient(SE);
  server = SE.createUDPServer("127.0.0.1", port);
  server.setClientAcceptor(serverFC);
  server.start();
}
 
开发者ID:threadly,项目名称:litesockets,代码行数:17,代码来源:NoThreadUDPTests.java

示例5: start

import org.threadly.concurrent.PriorityScheduler; //导入依赖的package包/类
@Before
public void start() throws Exception {
  PS = new PriorityScheduler(5);
  ntSE = new NoThreadSocketExecuter(); 
  SE = ntSE;
  SE.start();
  PS.execute(new Runnable() {
    @Override
    public void run() {
      ntSE.select(10);
      if(running) {
        PS.execute(this);
      }
    }});
  port = PortUtils.findTCPPort();
  KS = KeyStore.getInstance(KeyStore.getDefaultType());
  String filename = ClassLoader.getSystemClassLoader().getResource("keystore.jks").getFile();
  FileInputStream ksf = new FileInputStream(filename);
  KS.load(ksf, "password".toCharArray());
  kmf = KeyManagerFactory.getInstance("SunX509");
  kmf.init(KS, "password".toCharArray());
  sslCtx = SSLContext.getInstance("TLS");
  sslCtx.init(kmf.getKeyManagers(), myTMs, null);
  serverFC = new FakeTCPServerClient();
}
 
开发者ID:threadly,项目名称:litesockets,代码行数:26,代码来源:NoThreadSSLTests.java

示例6: start

import org.threadly.concurrent.PriorityScheduler; //导入依赖的package包/类
@Before
public void start() throws IOException {
  keepRunning = true;
  port = PortUtils.findTCPPort();
  STS = new SingleThreadScheduler();
  PS = new PriorityScheduler(5);
  ntSE = new NoThreadSocketExecuter();
  SE = ntSE;
  SE.start();
  STS.execute(new Runnable() {
    @Override
    public void run() {
      while(ntSE.isRunning() && keepRunning) {
        ntSE.select(1000);
      }
    }});
  serverFC = new FakeTCPServerClient();
  server = SE.createTCPServer("localhost", port);
  server.setClientAcceptor(serverFC);
  server.addCloseListener(serverFC);
  server.start();
}
 
开发者ID:threadly,项目名称:litesockets,代码行数:23,代码来源:NoThreadTCPTests.java

示例7: getResultTest

import org.threadly.concurrent.PriorityScheduler; //导入依赖的package包/类
@Test
public void getResultTest() throws InterruptedException, ExecutionException {
  final String testResult = StringUtils.makeRandomString(5);
  
  PriorityScheduler scheduler = new StrictPriorityScheduler(1);
  try {
    scheduler.schedule(new Runnable() {
      @Override
      public void run() {
        slf.setResult(testResult);
      }
    }, DELAY_TIME);
    
    assertTrue(slf.get() == testResult);
  } finally {
    scheduler.shutdownNow();
  }
}
 
开发者ID:threadly,项目名称:threadly,代码行数:19,代码来源:SettableListenableFutureTest.java

示例8: getWithTimeoutResultTest

import org.threadly.concurrent.PriorityScheduler; //导入依赖的package包/类
@Test
public void getWithTimeoutResultTest() throws InterruptedException, 
                                              ExecutionException, 
                                              TimeoutException {
  final String testResult = StringUtils.makeRandomString(5);
  
  PriorityScheduler scheduler = new StrictPriorityScheduler(1);
  try {
    scheduler.prestartAllThreads();
    scheduler.schedule(new Runnable() {
      @Override
      public void run() {
        slf.setResult(testResult);
      }
    }, DELAY_TIME);
    
    assertTrue(slf.get(DELAY_TIME + (SLOW_MACHINE ? 2000 : 1000), TimeUnit.MILLISECONDS) == testResult);
  } finally {
    scheduler.shutdownNow();
  }
}
 
开发者ID:threadly,项目名称:threadly,代码行数:22,代码来源:SettableListenableFutureTest.java

示例9: ScriptAssistant

import org.threadly.concurrent.PriorityScheduler; //导入依赖的package包/类
public ScriptAssistant() {
  running = new AtomicBoolean(false);
  scheduler = new AtomicReference<PriorityScheduler>(null);
  futures = new AtomicReference<List<ListenableFuture<StepResult>>>(null);
  markedFailure = new AtomicBoolean(false);
  failureListeners = new ArrayList<Runnable>(1);
  limiter = null;
}
 
开发者ID:threadly,项目名称:ambush,代码行数:9,代码来源:ExecutableScript.java

示例10: executeAsyncMaintenanceTaskIfStillRunning

import org.threadly.concurrent.PriorityScheduler; //导入依赖的package包/类
@Override
public void executeAsyncMaintenanceTaskIfStillRunning(Runnable task) {
  PriorityScheduler ps = scheduler.get();
  if (ps != null) {
    ps.execute(task, TaskPriority.Starvable);
  }
}
 
开发者ID:threadly,项目名称:ambush,代码行数:8,代码来源:ExecutableScript.java

示例11: setStepPerSecondLimit

import org.threadly.concurrent.PriorityScheduler; //导入依赖的package包/类
@Override
public void setStepPerSecondLimit(double newLimit) {
  if (newLimit <= 0) {
    limiter = null;
  } else {
    PriorityScheduler scheduler = this.scheduler.get();
    if (scheduler != null) {
      limiter = new RateLimiterExecutor(scheduler, newLimit);
    }
  }
}
 
开发者ID:threadly,项目名称:ambush,代码行数:12,代码来源:ExecutableScript.java

示例12: start

import org.threadly.concurrent.PriorityScheduler; //导入依赖的package包/类
@Before
public void start() throws IOException {
  port = PortUtils.findTCPPort();
  PS = new PriorityScheduler(2);
  TSE = new ThreadedSocketExecuter(PS);
  TSE.start();
  httpServer = TSE.createTCPServer("localhost", port);
  httpServer.start();
  httpServer.start();
}
 
开发者ID:threadly,项目名称:litesockets-http,代码行数:11,代码来源:WebSocketClientTest.java

示例13: TestHTTPServer

import org.threadly.concurrent.PriorityScheduler; //导入依赖的package包/类
public TestHTTPServer(int port, HTTPResponse hr, String sendBack, boolean doSSL, boolean closeOnSend) throws IOException {
  if(doSSL) {
    doSSLCrap();
  } 
  this.hr = hr;
  this.port = port;
  PS = new PriorityScheduler(5);
  SEB = new ThreadedSocketExecuter(PS);
  SEB.start();
  server = new HTTPServer(SEB, "localhost", port, sslCtx);
  server.addHandler(this);
  server.start();
  this.sendBack.add(ByteBuffer.wrap(sendBack.getBytes()));
  this.closeOnSend = closeOnSend;
}
 
开发者ID:threadly,项目名称:litesockets-http,代码行数:16,代码来源:TestHTTPServer.java

示例14: main

import org.threadly.concurrent.PriorityScheduler; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
  if (args.length < 1) {
    System.err.println("Usage: java -cp build/libs/heapDumpAnalyzer.java " + 
                          Parse.class.getName() + " dump.hprof");
    System.exit(1);
  }
  Profiler pf = new Profiler(10);
  PriorityScheduler scheduler = new PriorityScheduler(Runtime.getRuntime().availableProcessors() * 2);
  long start = Clock.accurateForwardProgressingMillis();
  try {
    HprofParser parser = new HprofParser(scheduler, new File(args[0]));
    if(args.length >= 2) {
      pf.start();
    }
    parser.parse();
    System.out.println("ParseTime:"+(Clock.accurateForwardProgressingMillis()-start));
    System.out.println("---------------------");
    long at = Clock.accurateForwardProgressingMillis();
    parser.analyze();
    System.out.println("---------------------");
    System.out.println("AnalyseTime:"+(Clock.accurateForwardProgressingMillis()-at));
  } finally {
    if(args.length >= 2) {
      pf.stop();
      File f = File.createTempFile("profile", "out");
      RandomAccessFile raf = new RandomAccessFile(f, "rw");
      raf.write(pf.dump().getBytes());
      raf.close();
    }
    System.out.println("---------------------");
    System.out.println("TotalTime:"+(Clock.accurateForwardProgressingMillis()-start));
    System.gc();
    System.out.println("---------------------");
    System.out.println("Used Memory:" + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));
    scheduler.shutdown();
  }
}
 
开发者ID:threadly,项目名称:heapDumpAnalyzer,代码行数:38,代码来源:Parse.java

示例15: start

import org.threadly.concurrent.PriorityScheduler; //导入依赖的package包/类
@Before
public void start() throws IOException {
  PS = new PriorityScheduler(5);
  SE = new ThreadedSocketExecuter(PS);
  SE.start();
  serverFC = new FakeUDPServerClient(SE);
  server = SE.createUDPServer("127.0.0.1", port);
  server.setClientAcceptor(serverFC);
  server.start();
}
 
开发者ID:threadly,项目名称:litesockets,代码行数:11,代码来源:UDPTest.java


注:本文中的org.threadly.concurrent.PriorityScheduler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。