From cee240acecf1e1df1c7106d91a76d7b415890c2f Mon Sep 17 00:00:00 2001 From: spamegg Date: Tue, 20 Aug 2024 10:03:43 +0300 Subject: [PATCH] ch08 done with simple/sync pipe --- src/main/scala/ch08/common/Pipe.scala | 1 - src/main/scala/ch08/syncPipe/main.scala | 19 ++++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/scala/ch08/common/Pipe.scala b/src/main/scala/ch08/common/Pipe.scala index 085aa2a..3651cd3 100644 --- a/src/main/scala/ch08/common/Pipe.scala +++ b/src/main/scala/ch08/common/Pipe.scala @@ -3,7 +3,6 @@ package ch08 import scalanative.unsigned.{UnsignedRichLong, UnsignedRichInt} import scalanative.unsafe.* import scalanative.libc.*, stdlib.*, string.strncpy - import collection.mutable import scala.util.{Try, Success, Failure} import concurrent.{Future, ExecutionContext, Promise} diff --git a/src/main/scala/ch08/syncPipe/main.scala b/src/main/scala/ch08/syncPipe/main.scala index d5ade5f..590d67f 100644 --- a/src/main/scala/ch08/syncPipe/main.scala +++ b/src/main/scala/ch08/syncPipe/main.scala @@ -2,7 +2,7 @@ package ch08 package syncPipe import scala.util.{Try, Success, Failure} -import ch07.LibUV.*, ch07.LibUVConstants.* +import ch07.LibUV.uv_run, ch07.LibUVConstants.UV_RUN_DEFAULT @main def run: Unit = @@ -22,3 +22,20 @@ def run: Unit = uv_run(ch07.EventLoop.loop, UV_RUN_DEFAULT) println("done") + +// 1 +// read 2 bytes from pipe 0 +// consumed 1 +// parsed: Success(1) +// saw number 1 +// 2 +// read 2 bytes from pipe 0 +// consumed 2 +// parsed: Success(2) +// saw number 2 +// foo +// read 4 bytes from pipe 0 +// consumed foo +// parsed: Failure(java.lang.NumberFormatException: For input string: "foo") +// error: java.lang.NumberFormatException: For input string: "foo" +// ^C