Fiber(Engine engine) { this.owner = engine; id = iotaGen.incrementAndGet(); if (isTraceEnabled()) { LOGGER.log(Level.FINE, "{0} created", getName()); } // if this is run from another fiber, then we naturally inherit its context classloader, // so this code works for fiber->fiber inheritance just fine. contextClassLoader = Thread.currentThread().getContextClassLoader(); }
Fiber(Engine engine) { this.owner = engine; id = iotaGen.incrementAndGet(); if (isTraceEnabled()) { LOGGER.log(Level.FINE, "{0} created", getName()); } // if this is run from another fiber, then we naturally inherit its context classloader, // so this code works for fiber->fiber inheritance just fine. contextClassLoader = Thread.currentThread().getContextClassLoader(); }
Fiber(Engine engine) { this.owner = engine; id = iotaGen.incrementAndGet(); if (isTraceEnabled()) { LOGGER.log(Level.FINE, "{0} created", getName()); } // if this is run from another fiber, then we naturally inherit its context classloader, // so this code works for fiber->fiber inheritance just fine. contextClassLoader = Thread.currentThread().getContextClassLoader(); }
/** * Returns true if the fiber is ready to execute. */ private boolean isReady(List<FiberContextSwitchInterceptor> originalInterceptors) { if (synchronous) { while (suspendedCount == 1) try { if (isTraceEnabled()) { LOGGER.log(Level.FINE, "{0} is blocking thread {1}", new Object[]{getName(), Thread.currentThread().getName()}); } condition.await(); // the synchronized block is the whole runSync method. } catch (InterruptedException e) { // remember that we are interrupted, but don't respond to it // right away. This behavior is in line with what happens // when you are actually running the whole thing synchronously. interrupted = true; } synchronized(this) { return interceptors == originalInterceptors; } } else { if (suspendedCount>0) return false; synchronized(this) { return interceptors == originalInterceptors; } } }
/** * Returns true if the fiber is ready to execute. */ private boolean isReady(List<FiberContextSwitchInterceptor> originalInterceptors) { if (synchronous) { while (suspendedCount == 1) try { if (isTraceEnabled()) { LOGGER.log(Level.FINE, "{0} is blocking thread {1}", new Object[]{getName(), Thread.currentThread().getName()}); } condition.await(); // the synchronized block is the whole runSync method. } catch (InterruptedException e) { // remember that we are interrupted, but don't respond to it // right away. This behavior is in line with what happens // when you are actually running the whole thing synchronously. interrupted = true; } synchronized(this) { return interceptors == originalInterceptors; } } else { if (suspendedCount>0) return false; synchronized(this) { return interceptors == originalInterceptors; } } }
/** * Returns true if the fiber is ready to execute. */ private boolean isReady(List<FiberContextSwitchInterceptor> originalInterceptors) { if (synchronous) { while (suspendedCount == 1) try { if (isTraceEnabled()) { LOGGER.log(Level.FINE, "{0} is blocking thread {1}", new Object[]{getName(), Thread.currentThread().getName()}); } condition.await(); // the synchronized block is the whole runSync method. } catch (InterruptedException e) { // remember that we are interrupted, but don't respond to it // right away. This behavior is in line with what happens // when you are actually running the whole thing synchronously. interrupted = true; } synchronized(this) { return interceptors == originalInterceptors; } } else { if (suspendedCount>0) return false; synchronized(this) { return interceptors == originalInterceptors; } } }
/** * Wakes up a suspended fiber and begins response processing. * @since 2.2.6 */ public void resumeAndReturn(@NotNull Packet resumePacket, boolean forceSync) { if(isTraceEnabled()) LOGGER.log(Level.FINE, "{0} resumed with Return Packet", getName()); next = null; resume(resumePacket, forceSync); }
/** * Wakes up a suspended fiber and begins response processing. * @since 2.2.6 */ public void resumeAndReturn(@NotNull Packet resumePacket, boolean forceSync) { if(isTraceEnabled()) LOGGER.log(Level.FINE, "{0} resumed with Return Packet", getName()); next = null; resume(resumePacket, forceSync); }
/** * Wakes up a suspended fiber and begins response processing. * @since 2.2.6 */ public void resumeAndReturn(@NotNull Packet resumePacket, boolean forceSync) { if(isTraceEnabled()) LOGGER.log(Level.FINE, "{0} resumed with Return Packet", getName()); next = null; resume(resumePacket, forceSync); }
setCompletionCallback(callback); if(isTraceEnabled()) LOGGER.log(Level.FINE, "{0} resuming. Will have suspendedCount={1}", new Object[]{getName(), suspendedCount-1}); packet = resumePacket; listener.fiberResumed(this); } catch (Throwable e) { if (isTraceEnabled()) LOGGER.log(Level.FINE, "Listener {0} threw exception: {1}", new Object[]{listener, e.getMessage()}); if (isTraceEnabled()) { LOGGER.log(Level.FINE, "{0} taking no action on resume because suspendedCount != 0: {1}", new Object[]{getName(), suspendedCount});
setCompletionCallback(callback); if(isTraceEnabled()) LOGGER.log(Level.FINE, "{0} resuming. Will have suspendedCount={1}", new Object[]{getName(), suspendedCount-1}); packet = resumePacket; listener.fiberResumed(this); } catch (Throwable e) { if (isTraceEnabled()) LOGGER.log(Level.FINE, "Listener {0} threw exception: {1}", new Object[]{listener, e.getMessage()}); if (isTraceEnabled()) { LOGGER.log(Level.FINE, "{0} taking no action on resume because suspendedCount != 0: {1}", new Object[]{getName(), suspendedCount});
/** * Wakes up a suspend fiber with an exception. * * If forceSync is true, then the suspended fiber will resume with * synchronous processing on the current thread. This will continue * until some Tube indicates that it is safe to switch to asynchronous * processing. * * @param error exception that is used in the resumed processing * @param packet Packet that will be visible on the Fiber after the resume * @param forceSync if processing begins synchronously * @since 2.2.8 */ public void resume(@NotNull Throwable error, @NotNull Packet packet, boolean forceSync) { if(isTraceEnabled()) LOGGER.log(Level.FINE, "{0} resumed with Return Throwable", getName()); next = null; throwable = error; resume(packet, forceSync); }
private void completionCheck() { lock.lock(); try { // Don't trigger completion and callbacks if fiber is suspended if(!isCanceled && contsSize==0 && suspendedCount == 0) { if(isTraceEnabled()) LOGGER.log(Level.FINE, "{0} completed", getName()); clearListeners(); condition.signalAll(); if (completionCallback != null) { if (throwable != null) { if (isDeliverThrowableInPacket) { packet.addSatellite(new ThrowableContainerPropertySet(throwable)); completionCallback.onCompletion(packet); } else completionCallback.onCompletion(throwable); } else completionCallback.onCompletion(packet); } } } finally { lock.unlock(); } }
/** * Wakes up a suspend fiber with an exception. * * If forceSync is true, then the suspended fiber will resume with * synchronous processing on the current thread. This will continue * until some Tube indicates that it is safe to switch to asynchronous * processing. * * @param error exception that is used in the resumed processing * @param packet Packet that will be visible on the Fiber after the resume * @param forceSync if processing begins synchronously * @since 2.2.8 */ public void resume(@NotNull Throwable error, @NotNull Packet packet, boolean forceSync) { if(isTraceEnabled()) LOGGER.log(Level.FINE, "{0} resumed with Return Throwable", getName()); next = null; throwable = error; resume(packet, forceSync); }
/** * Wakes up a suspend fiber with an exception. * * If forceSync is true, then the suspended fiber will resume with * synchronous processing on the current thread. This will continue * until some Tube indicates that it is safe to switch to asynchronous * processing. * * @param error exception that is used in the resumed processing * @param packet Packet that will be visible on the Fiber after the resume * @param forceSync if processing begins synchronously * @since 2.2.8 */ public void resume(@NotNull Throwable error, @NotNull Packet packet, boolean forceSync) { if(isTraceEnabled()) LOGGER.log(Level.FINE, "{0} resumed with Return Throwable", getName()); next = null; throwable = error; resume(packet, forceSync); }
private void completionCheck() { lock.lock(); try { // Don't trigger completion and callbacks if fiber is suspended if(!isCanceled && contsSize==0 && suspendedCount == 0) { if(isTraceEnabled()) LOGGER.log(Level.FINE, "{0} completed", getName()); clearListeners(); condition.signalAll(); if (completionCallback != null) { if (throwable != null) { if (isDeliverThrowableInPacket) { packet.addSatellite(new ThrowableContainerPropertySet(throwable)); completionCallback.onCompletion(packet); } else completionCallback.onCompletion(throwable); } else completionCallback.onCompletion(packet); } } } finally { lock.unlock(); } }
private void completionCheck() { lock.lock(); try { // Don't trigger completion and callbacks if fiber is suspended if(!isCanceled && contsSize==0 && suspendedCount == 0) { if(isTraceEnabled()) LOGGER.log(Level.FINE, "{0} completed", getName()); clearListeners(); condition.signalAll(); if (completionCallback != null) { if (throwable != null) { if (isDeliverThrowableInPacket) { packet.addSatellite(new ThrowableContainerPropertySet(throwable)); completionCallback.onCompletion(packet); } else completionCallback.onCompletion(throwable); } else completionCallback.onCompletion(packet); } } } finally { lock.unlock(); } }
private void dumpFiberContext(String desc) { if(isTraceEnabled()) { String action = null; String msgId = null;
private void dumpFiberContext(String desc) { if(isTraceEnabled()) { String action = null; String msgId = null;
private void dumpFiberContext(String desc) { if(isTraceEnabled()) { String action = null; String msgId = null;