Commit Graph
41 Commits
Author SHA1 Message Date
Johannes Weiss fe10c5c063 Change the class restriction on our protocols to AnyObject (#1702)
Motivation:

In all contemporary Swift versions, the `class` and the `AnyObject`
protocol restriction is the same. And `class` is deprecated which warns
on newer Swift compilers.

Modifications:

Replace `class` with `AnyObject`.

Result:

No warnings on newer Swift compilers.
2020-12-09 19:43:11 +00:00
Andrew Naylor 08c7821ba3 Correct typo in _ChannelOutboundHandler docs (#1628)
Motivation:

The doc block for `_ChannelOutboundHandler.read(context:)` mentions suppressing
a *flush*, it appears this is a copy-paste error from the docs for `flush(context:)`
above and should in fact refer to suppressing the *read*.

Modifications:

Substituted `read` for `flush` in the doc block for `_ChannelOutboundHandler.read(context:)`
2020-09-03 13:46:28 +01:00
Konrad `ktoso` Malawski ef2f86bb24 Fix minor typo in RemovableChannelHandler api docs (#924) 2019-03-25 09:39:03 +02:00
Johannes Weiss a41280919e rename ctx to context (#842)
Motivation:

`ctx` was always an abbreviation was 'context` and in Swift we don't
really use abbreviations, so let's fix it.

Modifications:

- rename all instances of `ctx` to `context`

Result:

- fixes #483
2019-02-25 18:20:22 +00:00
Johannes Weiss d938264fcb better ChannelHandler removal API (#767)
Motivation:

If ChannelHandler removal worked correctly, it was often either by
accident or by intricate knowledge about the implementation of the
ChannelHandler that is to be removed. Especially when it comes to
re-entrancy it mostly didn't work correctly.

Modifications:

- introduce a `RemovableChannelHandler` API
- raise allocation limit per HTTP connection by 1
  (https://bugs.swift.org/browse/SR-9905)

Result:

Make things work by contruction rather than accident
2019-02-12 11:27:48 +01:00
Cory Benfield a3fad287c3 Add docs to explain inbound/outbound (#142) 2018-03-19 19:38:24 +01:00
Semen Zhydenko 73e89833fc Fixed typos in comments 2018-03-15 22:11:46 +09:00
adamnemecek 0bbed6d72f * removed trailing whitespace (#52) 2018-03-02 15:40:52 +09:00
Johannes Weiß 73a805c7f6 minor stylistic improvements (#36)
Motivation:

Sometimes we deviated from the style the Swift stdlib sets out for no
reason.

Modifications:

Fixed some stylistic deviations.

Result:

Looks more Swift-like.
2018-02-26 15:52:49 +00:00
Norman Maurer eabbb2fa1c Add documentation for protocols and extensions in ChannelHandler (#7)
Motivation:

We should include docs for our core abstractions. This adds docs for ChannelHandler and sub-protocols.

Modifications:

Add docs.

Result:

More docs.
2018-02-22 18:02:28 +01:00
Johannes Weiss c7e47e75f3 remove flush promises
Motivation:

We have multiple reasons why flush promises weren't great, for example:

- writeAndFlush sounds like it's a write + flush optimisation but in
  reality it was more expensive (2 extra promises)
- the semantics were never quite clear
- lots of implementation complexity, especially for the datagram channel

Modifications:

- removed the flush promises in the API
- this deliberately doesn't do the PendingWritesManager simplifications
  that this unlocks

Result:

flush doesn't have a promise anymore.
2018-02-20 16:13:41 +00:00
Johannes Weiß 64eac6177c make inbound channel operations non-throwing
Motivation:

Except for blocking methods (which shouldn't be used on the event loop),
there aren't that many error cases that we should just send through the
pipeline automatically. Best proof for that is that nothing in the code
base did that. Therefore these methods shouldn't be throwing.

If the user does indeed want to catch and fire an error through the
pipeline that's still super simple `ctx.fireErrorCaught(error)`.

Modifications:

removed `throws` from the `ChannelInboundHandler` methods.

Result:

better
2018-02-19 18:10:21 +00:00
Norman Maurer 1912948fd4 Remove promise parameter on read method.
Motivation:

The promise on read is not very useful, we should just remove it.

Modifications:

Remove promise.

Result:

Cleaner code.
2018-02-19 21:39:46 +01:00
Johannes Weiss eaa8ffaee4 remove redundant labels
Motivation:

Lots of our most important operations had redundant labels like

    func write(data: NIOAny)

the `data: ` label doesn't add anything meaningful and therefore it
should be removed.

Modifications:

removed lots of redundant labels

Result:

less redundant labels
2018-02-13 11:13:30 +00:00
Norman Maurer 4d8cf1ff22 Add support for closing only the output / input side of the Channel. 2017-12-28 13:40:31 +01:00
Johannes Weiß 33fe401322 rename Future/Promise to EventLoopFuture/EventLoopPromise 2017-11-21 17:41:36 +00:00
Max (Swift) Moiseev 198d6b447b Explicit access modifiers on members in extensions 2017-11-18 04:40:26 -08:00
Johannes Weiß 6173bee782 Split IOData into NIOAny & IOData (ByteBuffer | FileRegion) 2017-10-25 19:31:27 +01:00
Johannes Weiss 1adb581f59 remove more Foundation imports 2017-10-10 16:25:43 +01:00
Johannes Weiß c09178ceb2 baby steps towards a type-safe Channel pipeline 2017-06-30 13:04:19 +01:00
Norman Maurer fd936557c4 Move Socket/* into NIO/ for max performance
Before:

`Bandwidth per channel: 18870.319⇅ Mbps (2358789.8 kBps)`

After:

`Bandwidth per channel: 21330.617⇅ Mbps (2666327.1 kBps)`
2017-07-03 14:52:09 +02:00
Norman Maurer 55fad73cd6 Introduce triggerUserOutboundEvent as this is a feature that we noticed is missing from netty 2017-07-03 09:56:16 +02:00
Norman Maurer 164cf244ac Swifty bind and connect method signature 2017-06-29 13:08:32 +02:00
Norman Maurer a9acf251e4 Have read and flush take an optional promise as well.
* Make Channel.read(...) take an optional promise so its more inline with the rest of the outbound operations

* Also let flush(...) take an optional promise and remove writeAndFlush(...)
2017-06-28 11:57:17 +02:00
Norman Maurer f35fb80c7e Make the promise optional for outbound operations.
This change allows the user to use `nil` as promise for outbound operations. This is useful if the user is not really interested in the outcome of the operations as it save extra allocations and so make things faster.

Before:
`Aggregate bandwidth: 10464.620↓, 10465.091↑ Mbps`

After (with using nil as Promise):

`Aggregate bandwidth: 11283.322↓, 11284.157↑ Mbps`
2017-06-27 14:37:24 +02:00
Norman Maurer dbb98eb905 Split ChannelHandler to ChannelInboundHandler and ChannelOutboundHandler
The mention change was done for performance reasons as often the user only either implement inbound or outbound operations per handler. The problem before was that we had to traverse the full list all the time even if the user was not really interested in either inbound or outbound events.

With this change we also split the doubly-linked-list into two linked-lists, one for inbound handlers and one for outbound handlers. This way we only need to traverse the handlers that are really interested in th event itself.

To give an idea about the impact of the change in terms of performance, here are some numbers.

Two ChannelInboundHandlers in the ChannelPipeline that do nothing and so just forward the events to the next handler in the pipeline:

Before:

`Bandwidth per channel: 18369.796⇅ Mbps (2296224.5 kBps)`

After:

`Bandwidth per channel: 20043.638⇅ Mbps (2505454.7 kBps)`
2017-06-21 14:35:33 +02:00
Norman Maurer 57cd379950 More consistent handling of writable state changes, so it matches netty 2017-06-19 15:05:29 +02:00
Johannes Weiß b73bfdab70 remove some existentials by specialising the data type (IOData) 2017-06-15 19:43:49 +01:00
Norman Maurer 58d0883b2d Fork Future-Swift and adjust it to ensure callback execution is always done on the EventLoop.
- Also remove all methods that use Dispatch for now as we not need these
- Ensure we will detect if the user calls a blocking method while on the EventLoop and crash to guard against deadlock
2017-06-12 13:44:10 +02:00
Norman Maurer c6685c3e7c Use types to allow the compile to specialize the methods 2017-06-09 15:47:10 +02:00
Norman Maurer db2002840d Add Channel.connect(...) and needed methods to Socket to support connect. This will allow us to support client and server easily in the future. 2017-05-24 22:13:17 +02:00
Norman Maurer 22d827f2da Mark methods with @discardableResult when its ok to discard the returned value 2017-05-24 14:17:40 +02:00
Norman Maurer f933093a1e Introduce ServerSocketChannel which will accept SocketChannel instances. Now the ServerSocket and the Socket are both handled directly via the EventLoop and make use of the pipeline just like in Netty. 2017-05-23 14:53:21 +02:00
Norman Maurer 0427eaff33 Add support for Channel.bind(...), this will also be needed once we support the ServerSocket via a Channel 2017-05-19 08:21:55 +02:00
Norman Maurer 53fe94869f Replace AnyObject with Any to allow passing classes and structs through the pipeline 2017-05-12 19:10:23 +02:00
Norman Maurer 7433a94743 Some visibility cleanup 2017-05-11 17:29:56 +02:00
Norman Maurer 6587222278 Make the pipeline more usable by adding add/remove/contains methods 2017-05-11 13:29:35 +02:00
Norman Maurer a2d301a4dc Replace AnyClass with AnyObject for user events 2017-05-10 07:49:22 +02:00
Norman Maurer 9780f68603 Use AnyObject for writes and reads to allow passing any object throught the pipeline 2017-05-10 07:42:28 +02:00
Norman Maurer 90d2e5a2e1 Add register and unregister callbacks 2017-05-09 19:23:39 +02:00
Norman Maurer e193bc97f0 Split into two different modules 2017-05-09 12:50:19 +02:00