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!
Okami
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();
fiber.start();
//use fiber for normal publishing and subscribing.
Answered by: Roland971 | Posted: 24-02-2022
Answer 2
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/
Answered by: Wilson462 | Posted: 24-02-2022Answer 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 | Dev.to Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)