Rename method to better reflect its usage and update some javadocs. See
#187 and #140
This commit is contained in:
parent
c2bc463d61
commit
301a17c029
@ -226,7 +226,7 @@ abstract class AbstractCodecEmbedder<E> implements CodecEmbedder<E> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireEventLater(ChannelPipeline pipeline, ChannelEvent e) throws Exception {
|
public void fireUpstreamEventLater(ChannelPipeline pipeline, ChannelEvent e) throws Exception {
|
||||||
handleEvent(e);
|
handleEvent(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import io.netty.channel.ChannelPipeline;
|
|||||||
public abstract class AbstractHttpChannelSink extends AbstractChannelSink{
|
public abstract class AbstractHttpChannelSink extends AbstractChannelSink{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireEventLater(ChannelPipeline pipeline, ChannelEvent e) throws Exception {
|
public void fireUpstreamEventLater(ChannelPipeline pipeline, ChannelEvent e) throws Exception {
|
||||||
pipeline.sendUpstream(e);
|
pipeline.sendUpstream(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -334,7 +334,7 @@ public class RxtxChannelSink extends AbstractChannelSink {
|
|||||||
* Just fire the event now by calling {@link ChannelPipeline#sendUpstream(ChannelEvent)} as this implementation does not support it otherwise
|
* Just fire the event now by calling {@link ChannelPipeline#sendUpstream(ChannelEvent)} as this implementation does not support it otherwise
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void fireEventLater(ChannelPipeline pipeline, ChannelEvent event) throws Exception {
|
public void fireUpstreamEventLater(ChannelPipeline pipeline, ChannelEvent event) throws Exception {
|
||||||
pipeline.sendUpstream(event);
|
pipeline.sendUpstream(event);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,13 +24,13 @@ import io.netty.channel.ChannelPipeline;
|
|||||||
public abstract class AbstractScptChannelSink extends AbstractChannelSink{
|
public abstract class AbstractScptChannelSink extends AbstractChannelSink{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireEventLater(final ChannelPipeline pipeline, final ChannelEvent e) throws Exception {
|
public void fireUpstreamEventLater(final ChannelPipeline pipeline, final ChannelEvent e) throws Exception {
|
||||||
Channel ch = e.getChannel();
|
Channel ch = e.getChannel();
|
||||||
if (ch instanceof SctpChannelImpl) {
|
if (ch instanceof SctpChannelImpl) {
|
||||||
SctpChannelImpl channel = (SctpChannelImpl) ch;
|
SctpChannelImpl channel = (SctpChannelImpl) ch;
|
||||||
// check if the current thread is a worker thread, and only fire the event later if thats not the case
|
// check if the current thread is a worker thread, and only fire the event later if thats not the case
|
||||||
if (channel.worker.thread != Thread.currentThread()) {
|
if (channel.worker.thread != Thread.currentThread()) {
|
||||||
channel.worker.fireEventLater(new Runnable() {
|
channel.worker.executeInIoThread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -245,7 +245,8 @@ class SctpWorker implements Worker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fireEventLater(Runnable eventRunnable) {
|
@Override
|
||||||
|
public void executeInIoThread(Runnable eventRunnable) {
|
||||||
assert eventQueue.offer(eventRunnable);
|
assert eventQueue.offer(eventRunnable);
|
||||||
|
|
||||||
// wake up the selector to speed things
|
// wake up the selector to speed things
|
||||||
|
@ -38,5 +38,8 @@ public interface ChannelSink {
|
|||||||
*/
|
*/
|
||||||
void exceptionCaught(ChannelPipeline pipeline, ChannelEvent e, ChannelPipelineException cause) throws Exception;
|
void exceptionCaught(ChannelPipeline pipeline, ChannelEvent e, ChannelPipelineException cause) throws Exception;
|
||||||
|
|
||||||
void fireEventLater(ChannelPipeline pipeline, ChannelEvent e) throws Exception;
|
/**
|
||||||
|
* Schedule the given {@link ChannelEvent} for later execution (in the io-thread). Some implementation may not support his and just fire it directly
|
||||||
|
*/
|
||||||
|
void fireUpstreamEventLater(ChannelPipeline pipeline, ChannelEvent e) throws Exception;
|
||||||
}
|
}
|
||||||
|
@ -586,7 +586,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
@Override
|
@Override
|
||||||
public void sendUpstreamLater(ChannelEvent e) {
|
public void sendUpstreamLater(ChannelEvent e) {
|
||||||
try {
|
try {
|
||||||
getSink().fireEventLater(this, e);
|
getSink().fireUpstreamEventLater(this, e);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
notifyHandlerException(e, t);
|
notifyHandlerException(e, t);
|
||||||
}
|
}
|
||||||
@ -843,7 +843,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireEventLater(ChannelPipeline pipeline, ChannelEvent e) throws Exception {
|
public void fireUpstreamEventLater(ChannelPipeline pipeline, ChannelEvent e) throws Exception {
|
||||||
if (logger.isWarnEnabled()) {
|
if (logger.isWarnEnabled()) {
|
||||||
logger.warn("Not attached yet; discarding: " + e);
|
logger.warn("Not attached yet; discarding: " + e);
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ public class IoStreamChannelSink extends AbstractChannelSink {
|
|||||||
* This just calls {@link ChannelPipeline#sendUpstream(ChannelEvent)} as the transport does not support it
|
* This just calls {@link ChannelPipeline#sendUpstream(ChannelEvent)} as the transport does not support it
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void fireEventLater(ChannelPipeline pipeline, ChannelEvent e) throws Exception {
|
public void fireUpstreamEventLater(ChannelPipeline pipeline, ChannelEvent e) throws Exception {
|
||||||
pipeline.sendUpstream(e);
|
pipeline.sendUpstream(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ final class LocalClientChannelSink extends AbstractChannelSink {
|
|||||||
* Just fire the event now by calling {@link ChannelPipeline#sendUpstream(ChannelEvent)} as this implementation does not support it otherwise
|
* Just fire the event now by calling {@link ChannelPipeline#sendUpstream(ChannelEvent)} as this implementation does not support it otherwise
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void fireEventLater(ChannelPipeline pipeline, ChannelEvent event) throws Exception {
|
public void fireUpstreamEventLater(ChannelPipeline pipeline, ChannelEvent event) throws Exception {
|
||||||
pipeline.sendUpstream(event);
|
pipeline.sendUpstream(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ final class LocalServerChannelSink extends AbstractChannelSink {
|
|||||||
* Just fire the event now by calling {@link ChannelPipeline#sendUpstream(ChannelEvent)} as this implementation does not support it otherwise
|
* Just fire the event now by calling {@link ChannelPipeline#sendUpstream(ChannelEvent)} as this implementation does not support it otherwise
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void fireEventLater(ChannelPipeline pipeline, ChannelEvent event) throws Exception {
|
public void fireUpstreamEventLater(ChannelPipeline pipeline, ChannelEvent event) throws Exception {
|
||||||
pipeline.sendUpstream(event);
|
pipeline.sendUpstream(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,16 @@
|
|||||||
|
|
||||||
package io.netty.channel.socket;
|
package io.netty.channel.socket;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A {@link Worker} is responsible to dispatch IO operations
|
||||||
|
*
|
||||||
|
*/
|
||||||
public interface Worker extends Runnable{
|
public interface Worker extends Runnable{
|
||||||
|
|
||||||
void fireEventLater(Runnable eventRunnable);
|
/**
|
||||||
|
* Execute the given {@link Runnable} in the IO-Thread. This may be now or later once the IO-Thread do some other work.
|
||||||
|
*
|
||||||
|
* @param task the {@link Runnable} to execute
|
||||||
|
*/
|
||||||
|
void executeInIoThread(Runnable task);
|
||||||
}
|
}
|
||||||
|
@ -24,13 +24,13 @@ import io.netty.channel.ChannelPipeline;
|
|||||||
public abstract class AbstractNioChannelSink extends AbstractChannelSink{
|
public abstract class AbstractNioChannelSink extends AbstractChannelSink{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireEventLater(final ChannelPipeline pipeline, final ChannelEvent e) throws Exception {
|
public void fireUpstreamEventLater(final ChannelPipeline pipeline, final ChannelEvent e) throws Exception {
|
||||||
Channel ch = e.getChannel();
|
Channel ch = e.getChannel();
|
||||||
if (ch instanceof AbstractNioChannel<?>) {
|
if (ch instanceof AbstractNioChannel<?>) {
|
||||||
AbstractNioChannel<?> channel = (AbstractNioChannel<?>) ch;
|
AbstractNioChannel<?> channel = (AbstractNioChannel<?>) ch;
|
||||||
// check if the current thread is a worker thread if so we can send the event now
|
// check if the current thread is a worker thread if so we can send the event now
|
||||||
if (channel.worker.thread != Thread.currentThread()) {
|
if (channel.worker.thread != Thread.currentThread()) {
|
||||||
channel.worker.fireEventLater(new Runnable() {
|
channel.worker.executeInIoThread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -271,7 +271,8 @@ abstract class AbstractNioWorker implements Worker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void fireEventLater(Runnable eventRunnable) {
|
@Override
|
||||||
|
public void executeInIoThread(Runnable eventRunnable) {
|
||||||
assert eventQueue.offer(eventRunnable);
|
assert eventQueue.offer(eventRunnable);
|
||||||
|
|
||||||
// wake up the selector to speed things
|
// wake up the selector to speed things
|
||||||
|
@ -25,13 +25,13 @@ import io.netty.channel.socket.Worker;
|
|||||||
public abstract class AbstractOioChannelSink extends AbstractChannelSink{
|
public abstract class AbstractOioChannelSink extends AbstractChannelSink{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireEventLater(final ChannelPipeline pipeline, final ChannelEvent e) throws Exception {
|
public void fireUpstreamEventLater(final ChannelPipeline pipeline, final ChannelEvent e) throws Exception {
|
||||||
Channel ch = e.getChannel();
|
Channel ch = e.getChannel();
|
||||||
if (ch instanceof AbstractOioChannel) {
|
if (ch instanceof AbstractOioChannel) {
|
||||||
AbstractOioChannel channel = (AbstractOioChannel) ch;
|
AbstractOioChannel channel = (AbstractOioChannel) ch;
|
||||||
Worker worker = channel.worker;
|
Worker worker = channel.worker;
|
||||||
if (worker != null && channel.workerThread != Thread.currentThread()) {
|
if (worker != null && channel.workerThread != Thread.currentThread()) {
|
||||||
channel.worker.fireEventLater(new Runnable() {
|
channel.worker.executeInIoThread(new Runnable() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -91,8 +91,10 @@ abstract class AbstractOioWorker<C extends AbstractOioChannel> implements Worker
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void fireEventLater(Runnable eventRunnable) {
|
public void executeInIoThread(Runnable eventRunnable) {
|
||||||
assert eventQueue.offer(eventRunnable);
|
assert eventQueue.offer(eventRunnable);
|
||||||
|
|
||||||
|
// as we set the SO_TIMEOUT to 1 second this task will get picked up in 1 second at latest
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processEventQueue() throws IOException {
|
private void processEventQueue() throws IOException {
|
||||||
|
Loading…
Reference in New Issue
Block a user