Jetlang PoolFiber sample

I started with jetlang and the basic samples are pretty clear. What I didn't found is a good sample for using the PoolFiber. Anybody played around with that already? I read also the retlang samples but it seems little bit different there.

Thanks for sharing your thoughts!


Asked by: Catherine524 | Posted: 23-01-2022

Answer 1

Using a PoolFiber and ThreadFiber are nearly the same. The only difference is that the thread pool needs to initialized and used for creating each PoolFiber.

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

Answered by: Roland971 | Posted: 24-02-2022

Answer 2

Here it is on Github.

Here's the mvn site

Answered by: Wilson462 | Posted: 24-02-2022

Answer 3

A better pool than Cache is, in involve number of CPU core related to 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);

Answered by: Victoria884 | Posted: 24-02-2022

Similar questions

Still can't find your answer? Check out these amazing Java communities for help...

Java Reddit Community | Java Help Reddit Community | Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)