Example usage for io.netty.util.concurrent EventExecutor inEventLoop

List of usage examples for io.netty.util.concurrent EventExecutor inEventLoop

Introduction

In this page you can find the example usage for io.netty.util.concurrent EventExecutor inEventLoop.

Prototype

boolean inEventLoop(Thread thread);

Source Link

Document

Return true if the given Thread is executed in the event loop, false otherwise.

Usage

From source file:dorkbox.network.connection.Shutdownable.java

License:Apache License

/**
 * Check to see if the current thread is running from it's OWN thread, or from Netty... This is used to prevent deadlocks.
 *
 * @return true if the specified thread is as Netty thread, false if it's own thread.
 *///  w  w w.  ja v a2  s . co  m
protected boolean isInEventLoop(Thread thread) {
    for (EventLoopGroup loopGroup : eventLoopGroups) {
        for (EventExecutor next : loopGroup) {
            if (next.inEventLoop(thread)) {
                return true;
            }
        }
    }

    return false;
}