puniverse / quasar

Fibers, Channels and Actors for the JVM

Home Page:http://docs.paralleluniverse.co/quasar/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can i use Future.get() in Fiber task?

LingXi1420 opened this issue · comments

I need to call a method in another lib, but the method have Future and ReentrantLock, like this :

 public CompletableFuture<EslMessage> sendApiSingleLineCommand(Channel channel, final String command) {		
   
 final CompletableFuture<Message> future = new CompletableFuture<>();		
  
      try {
		syncLock.lock(); //  ReentrantLock syncLock = new ReentrantLock();
		apiCalls.add(future);
		channel.writeAndFlush(command);
	} finally {
		syncLock.unlock();
	}
return future;
  }

then I called getUnchecked(sendApiSingleLineCommandchannel, sendMsg.getMsgLines())) to get the Future.get()

sometimes it runs ok, but sometimes it keeps warning and blocked Fiber, errors info:
WARNING: fiber Fiber@10000650:HangUpCallEvent[task: ParkableForkJoinTask@17a4ac30(Fiber@10000650), target: co.paralleluniverse.strands.SuspendableUtils$VoidSusp
endableCallable@559545a3, scheduler: co.paralleluniverse.fibers.FiberForkJoinScheduler@6762b60d] is blocking a thread (Thread[ForkJoinPool-default-fiber-pool-wo
rker-7,5,main]).
at sun.misc.Unsafe.park(Native Method)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)
at java.util.concurrent.CompletableFuture$Signaller.block(CompletableFuture.java:1693)
at java.util.concurrent.ForkJoinPool.managedBlock(ForkJoinPool.java:3323)
at java.util.concurrent.CompletableFuture.waitingGet(CompletableFuture.java:1729)
at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
at com.google.common.util.concurrent.Uninterruptibles.getUninterruptibly(Uninterruptibles.java:237)
at com.google.common.util.concurrent.Futures.getUnchecked(Futures.java:1326)

Guys, give me a hand....