- Jayo loves Kotlin !
- Support Kotlin specific types like
Sequence<T>
,kotlin.time.DurationUnit
, and maybe some coroutine's stuff likeFlow<T>
must only be implemented as extension functions (= Java will not see it). - If any Kotlin specific dependency has to be supported (
kotlinx.coroutines ?), it must be declared as
compileOnly
in gradle build. - Expose Type-safe Builders for Kotlin to configure client and server options
- Support Kotlin specific types like
- For server modules : a platform Thread can be used to Accept incoming connections, and virtual thread will handle all the rest.
- Servers will have a
close
method (fromAutoClosable
) that will refuse new incoming connections and requests, but will wait until current responses are returned. AcloseImmediatly
could be provided also, that aggressively closes immediately. - Shenandoah and ZGC new garbage collectors are available now, and improvements have been added to the other garbage collectors like G1. We could provide a guideline to GC configuration for Jayo users.
- Java 1.8
LongAdder
andLongAccumulator
: expose lock-free operations with longs (also exists with doubles)
- Java 9
- Project Jigsaw JPMS modules
- Compact Strings : The new String class store characters encoded either as ISO-8859-1/Latin-1 (one byte per character), or as UTF-16 (two bytes per character).
- Java 11
- Adds TLSv1.3 support
- Java 13
- Reimplementation of the Legacy Socket API with non-blocking under the hood
- Java 14
- Foreign memory (incubator)
- Non-Volatile Mapped Byte Buffers
- Java 15
- Reimplementation of the Legacy DatagramSocket API with non-blocking under the hood
- Java 16
- Java 18
- Java 19
- Project Loom virtual threads (preview)
- Foreign memory (promoted from incubator to preview)
- Structured Concurrency (incubator)
- Quic / HTTP3
- IP_DONTFRAGMENT was added, it is required for the QUIC implementation, see
this JDK issue,
https://www.rfc-editor.org/rfc/rfc9000.html#name-datagram-size
datagramSocket.setOption(ExtendedSocketOptions.IP_DONTFRAGMENT, true)
- IP_DONTFRAGMENT was added, it is required for the QUIC implementation, see
this JDK issue,
https://www.rfc-editor.org/rfc/rfc9000.html#name-datagram-size
- Java 20
- Scoped Values (incubator)
- Java 21
- Project Loom virtual threads are promoted as stable
- Warning -> preview : Structured Concurrency treats multiple tasks running in different threads as a single unit of work, thereby streamlining error handling and cancellation, improving reliability, and enhancing observability.
- Warning -> preview : Scoped Values enable the sharing of immutable data within and across threads. They are preferred to thread-local variables, especially when using large numbers of virtual threads.
- Sequenced Collections This feature injects new interfaces into the existing Java collections hierarchy, offering a seamless mechanism to access the first and last elements of a collection using built-in default methods. Moreover, it provides support to obtain a reversed view of the collection.
- Java 22
- Foreign memory is promoted as stable. Sophisticated clients deserve an API that can allocate, manipulate, and share off-heap memory with the same fluidity and safety as on-heap memory. Such an API should balance the need for predictable deallocation with the need to prevent untimely deallocation that can lead to JVM crashes or, worse, to silent memory corruption.
Avoiding race conditions is an art, to avoid them when mutating a Segment
(= a write, transfer or remove operation),
we must follow a few steps in this exact order :
- switch the
Segment
state to the desired state - modify
pos
orlimit
- increase or decrease the byte size of the
SegmentQueue
- atomically
compareAndSet
the TAIL or the HEAD - (optional) atomically update the NEXT segment
- end the operation by resetting the
Segment
state toAVAILABLE
, or recycle it in the segment pool if this segment was fully read
We must battle test these potential race conditions with a lot of tests and benchmarks, sometimes with some Random
involved to create all sorts of weird use cases !
- Okio documentation and related articles
- Okio recipes
- Okio with socket
- A closer look at the Okio library
- Okio.Options
- Forcing bytes downward in Okio : flush() VS emit() VS emitCompleteSegments()
- With a file you’re either reading or writing but with the network you can do both! Some protocols handle this by
taking turns: write a request, read a response, repeat. You can implement this kind of protocol with a single thread.
In other protocols you may read and write simultaneously. Typically, you’ll want one dedicated thread for reading. For
writing, you can use either a single dedicated thread or use
Locks
so that multiple threads can share a sink. Okio’s streams are not safe for concurrent use.
- kotlinx-io is a Kotlin only simplified and optimized fork of Okio
- ktor-io is a Kotlin only coroutines I/O framework
- Netty is the most advanced and powerful async I/O framework written in Java
- Quasar is the loom ancestor on JDK
- Chronicle Bytes
- jox : Fast and Scalable Channels in Java
- Nice usage of java
Stream<T>
like in Spring'sResultSetSpliterator
inJdbcTemplate
class - Loom support added in Okio
- Timeouts and cancellation for humans inspiration for the cancellation mechanism in Jayo