Skip to content

Commit

Permalink
ch08 done with simple/sync pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
spamegg1 committed Aug 20, 2024
1 parent 100ef63 commit cee240a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/main/scala/ch08/common/Pipe.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
19 changes: 18 additions & 1 deletion src/main/scala/ch08/syncPipe/main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -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

0 comments on commit cee240a

Please sign in to comment.