Commit Graph

26 Commits

Author SHA1 Message Date
Trustin Lee
421eabe666 [#473] Fix elevated context switching in SingleThreadEventExecutor
- Remove polling in SingleThreadEventExecutor
- Create a dedicated scheduled task scheduler called 'TaskScheduler'
- TaskScheduler is created per EventLoopGroup / EventExecutorGroup
- SingleThreadEventExecutor delegates all scheduled execution requests
  to TaskScheduler provided as a constructor parameter
- TaskScheduler is a specialized form of single threaded 
  ScheduledExecutorService which requires an EventExecutor as a
  parameter for all requests.
2012-08-18 18:40:21 +09:00
Trustin Lee
d298707198 [#502] Split EventLoop/EventExecutor into parent and children
- Add EventExecutorGroup and EventLoopGroup
- EventExecutor and EventLoop extends EventExecutorGroup and
  EventLoopGroup
  - They form their own group so that .next() returns itself.
- Rename Bootstrap.eventLoop() to group()
- Rename parameter names such as executor to group
- Rename *EventLoop/Executor to *EventLoop/ExecutorGroup
- Rename *ChildEventLoop/Executor to *EventLoop/Executor
2012-08-10 20:17:18 +09:00
Trustin Lee
42380b54b3 Revert file mode 2012-07-07 14:39:35 +09:00
Norman Maurer
f8ef5d5d78 Next round for async channel api support a.k.a nio2. See See #396 2012-06-14 21:02:47 +02:00
Trustin Lee
1eced1e9e3 Update license headers 2012-06-04 13:31:44 -07:00
Trustin Lee
04cf1c8199 Use custom thread factory by default to better recognize the threads
... from their names
2012-06-01 22:57:54 -07:00
Trustin Lee
61e169e53a Remove EventExecutor.parent(), which is of no use 2012-06-01 22:33:53 -07:00
Trustin Lee
141a05c831 Strict thread model / Allow assign an executor to a handler
- Add EventExecutor and make EventLoop extend it
- Add SingleThreadEventExecutor and MultithreadEventExecutor
- Add EventExecutor's default implementation
- Fixed an API design problem where there is no way to get non-bypass
  buffer of desired type
2012-06-01 17:51:19 -07:00
Trustin Lee
42abb6df3a QueueFactory cleanup
- Really attempt to create a queue to determine LTQ can be initialized
  in runtime, and cache the result
- Remove unnecessary Class<T> parameter in createQueue()
- Remove unused createQueue(Collection)
2012-05-30 16:19:22 -07:00
Trustin Lee
47fa2ef2e8 Use LinkedHashSet instead of HashSet to preserve order of execution 2012-05-30 10:17:45 -07:00
Trustin Lee
c17e5b458a Typo 2012-05-30 04:28:01 -07:00
Trustin Lee
4154f42520 Less restriction in shutdown hook modification 2012-05-30 04:27:19 -07:00
Trustin Lee
078a502c5f Add shutdown hooks to SingleThreadEventLoop
- LocalChannel and LocalServerChannel uses it to close themselves on
  shutdown
- LocalEcho example does not call close() anymore because the channels
  are closed automatically on shutdown
2012-05-30 04:23:15 -07:00
Trustin Lee
e48281471b Limit future notification stack depth / Robost writeCounter management
- Also ported the discard example while testing this commit
2012-05-28 05:05:49 -07:00
Trustin Lee
7327bb3522 Add SingleThreadEventLoop.runAllTasks()
- Removed duplicated processTaskQueue() in child event loops
- Simplified the cleanup of cancelled keys in NIO transport
2012-05-27 04:43:48 -07:00
Trustin Lee
e2d69120bb Ported OIO socket/datagram transport to the new API 2012-05-25 13:58:56 -07:00
Trustin Lee
59f11ed64f Optimize AbstractChannel and related classes
- AbstractChannel.doRead() is split into two versions so that the
  implementation doesn't have to validate the buffer type.
- Optimized ChannelBufferHolder a little bit
- Reduced GC related with flush future notification
  - Added FlushCheckpoint and DefaultChannelFuture implements it
    opportunistically
-
2012-05-25 06:16:25 -07:00
Trustin Lee
25599018f2 Tiny bit of optimization in event loop 2012-05-24 21:04:12 -07:00
Trustin Lee
83026f29a4 Make EventLoop a ScheduledExecutorService
- SingleThreadEventLoop now implements ScheduledExecutorService
  - Scheduled tasks are automatically fetched into taskQueue by
    pollTask() and takeTask()
- Removed MapBackedSet because Java 6 provides it
2012-05-11 20:19:57 +09:00
Trustin Lee
cb718a07c8 Move ChannelFutureFactory.newVoidFuture() to Channel.Unsafe() / Cleanup 2012-05-11 00:57:42 +09:00
Trustin Lee
129a2af86a Initial working version of the echo server example
- Optimized AbstractChannelBuffer.discardReadBytes()
- Split ChannelHandlerInvoker into ChannelInboundInvoker and
  ChannelOutboundInvoker
  - Channel implements ChannelOutboundInvoker
  - ChannelOutboundInvoker.nextOut() is now out()
  - ChannelOutboundHandlerContext.out() is now prevOut()
  - Added the outbound operations without future
    parameter to ChannelOutboundInvoker for user convenience
- All async operations which requires a ChannelFuture as a parameter
  now returns ChannelFuture for user convenience
- Added ChannelFutureFactory.newVoidFuture() to allow a user specify
  a dummy future that is of no use
  - I'm unsure if it is actually a good idea to introduce it. It might
    go away later.
- Made the contract of AbstractChannel.doXXX() much simpler and moved
  all common code up to AbstractChannel.DefaultUnsafe
- Added Channel.isOpen()
- Fixed a bug where MultithreadEventLoop always shut down its child
  event loops on construction
- Maybe more changes I don't remember :-)
2012-05-09 22:09:06 +09:00
Trustin Lee
9e6f8b46df Retrofit the NIO transport with the new API / improve the new API
- Remove the classes and properties that are not necessary anymore
- Remove SingleThreadEventLoop.newRegistrationTask() and let
  Channel.Unsafe handle registration by itself
- Channel.Unsafe.localAddress() and remoteAddress()
  - JdkChannel is replaced by Channel.Unsafe.
2012-05-02 15:01:58 +09:00
Trustin Lee
470e7da5d7 Add MultithreadEventLoop
- Add EventLoopException to wrap the exceptions while an event loop does
something
- Make EventLoop.register() return EventLoop so that the caller knows
the actual EventLoop that will handle the Channel even if the caller
called register() from MultithreadEventLoop
2012-04-29 18:40:55 +09:00
Trustin Lee
e76e2aeac8 Add missing @Override annotation 2012-04-29 17:59:42 +09:00
Trustin Lee
0d8afa7a4c attach -> register 2012-04-03 22:19:35 +09:00
Trustin Lee
116054a364 Initial incomplete checkin of the event loop API 2012-04-03 22:03:04 +09:00