Skip to content

Commit 0886e67

Browse files
authored
Update to Scala Native 0.4.4 and remove workaround (#42)
1 parent d44c78b commit 0886e67

File tree

5 files changed

+15
-16
lines changed

5 files changed

+15
-16
lines changed

core/src/main/scala/scala/scalanative/loop/Eventloop.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ object EventLoop {
2727

2828
def run(): Unit = {
2929
while (uv_loop_alive(loop) != 0 || queue.nonEmpty) {
30-
while(queue.nonEmpty) {
30+
while (queue.nonEmpty) {
3131
val runnable = queue.remove(0)
3232
try {
3333
runnable.run()
@@ -66,9 +66,7 @@ object LibUV {
6666
type PrepareCB = CFuncPtr1[PrepareHandle, Unit]
6767
type ShutdownCB = CFuncPtr2[ShutdownReq, Int, Unit]
6868
type CloseCB = CFuncPtr1[UVHandle, Unit]
69-
// Workaround for https://github.com/scala-native/scala-native/issues/2550
70-
// Use `Int` instead of `Integer` once fixed
71-
type PollCB = CFuncPtr3[PollHandle, Integer, Integer, Unit]
69+
type PollCB = CFuncPtr3[PollHandle, Int, Int, Unit]
7270
type TimerCB = CFuncPtr1[TimerHandle, Unit]
7371
type FSCB = CFuncPtr1[FSReq, Unit]
7472

core/src/main/scala/scala/scalanative/loop/Poll.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class RWResult(val result: Int, val readable: Boolean, val writable: Boolean)
3939
object Poll {
4040
private val pollReadWriteCB: PollCB = (
4141
handle: PollHandle,
42-
status: Integer,
43-
events: Integer
42+
status: Int,
43+
events: Int
4444
) => {
4545
val callback =
4646
HandleUtils.getData[RWResult => Unit](handle)
@@ -54,16 +54,16 @@ object Poll {
5454
}
5555
private val pollReadCB: PollCB = (
5656
handle: PollHandle,
57-
status: Integer,
58-
events: Integer
57+
status: Int,
58+
events: Int
5959
) => {
6060
val callback = HandleUtils.getData[Int => Unit](handle)
6161
if ((events & UV_READABLE) != 0) callback.apply(status)
6262
}
6363
private val pollWriteCB: PollCB = (
6464
handle: PollHandle,
65-
status: Integer,
66-
events: Integer
65+
status: Int,
66+
events: Int
6767
) => {
6868
val callback = HandleUtils.getData[Int => Unit](handle)
6969
if ((events & UV_WRITABLE) != 0) callback.apply(status)

core/src/main/scala/scala/scalanative/loop/internals/HandleUtils.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ private[loop] object HandleUtils {
1414
@inline def getData[T <: Object](handle: Ptr[Byte]): T = {
1515
// data is the first member of uv_loop_t
1616
val ptrOfPtr = handle.asInstanceOf[Ptr[Ptr[Byte]]]
17-
val dataPtr = !ptrOfPtr
17+
val dataPtr = !ptrOfPtr
1818
if (dataPtr == null) null.asInstanceOf[T]
1919
else {
2020
val rawptr = toRawPtr(dataPtr)
@@ -24,7 +24,7 @@ private[loop] object HandleUtils {
2424
@inline def setData(handle: Ptr[Byte], obj: Object): Unit = {
2525
// data is the first member of uv_loop_t
2626
val ptrOfPtr = handle.asInstanceOf[Ptr[Ptr[Byte]]]
27-
if(obj != null) {
27+
if (obj != null) {
2828
if (references.contains(obj)) references(obj) += 1
2929
else references(obj) = 1
3030
val rawptr = castObjectToRawPtr(obj)
@@ -37,7 +37,7 @@ private[loop] object HandleUtils {
3737
stdlib.free(handle)
3838
}
3939
@inline def close(handle: Ptr[Byte]): Unit = {
40-
if(getData(handle) != null) {
40+
if (getData(handle) != null) {
4141
uv_close(handle, onCloseCB)
4242
val data = getData[Object](handle)
4343
val current = references(data)

core/src/test/scala/scala/scalanative/loop/TimerTests.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ object TimerTests extends LoopTestSuite {
5252
} yield ()
5353
}
5454
test("close multiple times") {
55-
val p = Promise[Unit]()
55+
val p = Promise[Unit]()
5656
val timer = Timer.timeout(10.millis)(() => {})
5757
timer.clear()
5858
timer.clear()
@@ -66,7 +66,8 @@ object TimerTests extends LoopTestSuite {
6666
}
6767
test("deadlock when futures need event loop run to unlock") {
6868
var completed = false
69-
def recursive(): Future[Unit] = if (!completed) Future(recursive()) else Future.successful(())
69+
def recursive(): Future[Unit] =
70+
if (!completed) Future(recursive()) else Future.successful(())
7071
val r = recursive()
7172
Timer.timeout(10.millis)(() => completed = true)
7273
r

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.3")
1+
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.4")
22
addSbtPlugin("com.eed3si9n" % "sbt-dirty-money" % "0.2.0")
33
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
44
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.4")

0 commit comments

Comments
 (0)