Remove non-blocking mode for ports to avoid CPU clogging.
This commit is contained in:
parent
ced42779be
commit
22359a5570
@ -53,12 +53,10 @@ public abstract class AbstractPort(
|
||||
/**
|
||||
* Internal method to receive data synchronously
|
||||
*/
|
||||
protected fun receive(data: ByteArray) {
|
||||
scope.launch {
|
||||
protected suspend fun receive(data: ByteArray) {
|
||||
logger.debug { "${this@AbstractPort} RECEIVED: ${data.decodeToString()}" }
|
||||
incoming.send(data)
|
||||
}
|
||||
}
|
||||
|
||||
private val sendJob = scope.launch {
|
||||
for (data in outgoing) {
|
||||
|
@ -87,9 +87,7 @@ public object TcpPort : PortFactory {
|
||||
port: Int,
|
||||
coroutineContext: CoroutineContext = context.coroutineContext,
|
||||
): ChannelPort = ChannelPort(context,coroutineContext){
|
||||
SocketChannel.open(InetSocketAddress(host, port)).apply {
|
||||
configureBlocking(false)
|
||||
}
|
||||
SocketChannel.open(InetSocketAddress(host, port))
|
||||
}
|
||||
|
||||
override fun build(context: Context, meta: Meta): ChannelPort {
|
||||
@ -115,7 +113,6 @@ public object UdpPort : PortFactory {
|
||||
): ChannelPort = ChannelPort(context,coroutineContext){
|
||||
DatagramChannel.open().apply {
|
||||
connect(InetSocketAddress(host, port))
|
||||
configureBlocking(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user