Jetlang PoolFiber Sample

I started with jetlang and the basic patterns are pretty clear. What I haven't found is a good example of using PoolFiber. Has anyone played around with this already? I've read the retlang samples as well, but it seems a little different.

Thanks for sharing your thoughts!

Key

+1


source to share


3 answers


The use of PoolFiber and ThreadFiber is almost the same. The only difference is that a thread pool must be initialized and used to create each pool.



// create java thread pool.
ExecutorService pool = Executors.newCachedThreadPool();
//initialize factory with backing pool
PoolFiberFactory fiberFactory = new PoolFiberFactory(pool);
Fiber fiber = fiberFactory.create();
fiber.start();
//use fiber for normal publishing and subscribing.

      

+5


source


Here it is on Github.

https://github.com/jetlang/jetlang/blob/readme/src/test/java/org/jetlang/examples/BasicExamples.java



Here's the mvn site http://jetlang.github.io/jetlang/

0


source


Better pool than Cache includes the number of CPU cores associated with the JVM:

int availableProcessors = Runtime.getRuntime().availableProcessors();
int threadPoolSize = availableProcessors*2;
ThreadPoolExecutor POOL = new ThreadPoolExecutor(threadPoolSize,
    threadPoolSize, 0L, TimeUnit.MILLISECONDS,  
    new LinkedBlockingQueue<Runnable>());
PoolFiberFactory fiberFactory = new PoolFiberFactory(POOL);

      


0


source







All Articles