* 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(...)
- Move ChannelInboundInvoker and ChannelOutboundInvoker to ChannelInvoker
- Add ChannelInvoker protocol which extends ChannelInboundInvoker and ChannelOutboundInvoker
- Let ChannelPipeline and ChannelHandlerContext implement ChannelInvoker
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`
The user should use callbacks to access the value / error of the promise or wait() and not try to get it directly. This also did not work correctly because it was not correctly implemented in terms of thread-safety
Make the Promise a struct to improve performance. As the Promise only contains a reference it also not change any semantics for the user.
Before:
`Bandwidth per channel: 14367.103⇅ Mbps (1795887.9 kBps)`
After:
`Bandwidth per channel: 14772.899⇅ Mbps (1846612.4 kBps)`
motivation: be able to build and test on linux
changes:
* add dockerfile to create docker image running all toold required for testing on linux
* add readme with instruction on how to use the docker setup
* add script to generate linux tests mapping
* add .swift_version file to explicitly call out the swift version needed to build the project
* adjust code that did not build on linux, mainly casting between Int32 and Int
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)`
Also move the readIfNeeded() logic to Channel as it really belongs there.
Before:
`Bandwidth per channel: 19004.576⇅ Mbps (2375571.9 kBps)`
After:
`Bandwidth per channel: 21851.957⇅ Mbps (2731494.6 kBps)`
* Remove unneeded hashValue from Future
And use Lock instead of NSLock. Seeing modest perf improvements.
* Annotate Promise and Future with final
* Use pthread_self equality rather than Thread
Seeing a 5x speedup in microbenchmarks