Scoop API

scoop:scoop.asyncio:0.1.0

src/loop/completion.scoop

Selected production source · src/loop/completion.scoop

1package scoop.asyncio
3import scoop.platform.system.*
5internal struct NativeEvent(val id: Long, val result: IoResult)
7internal enum IoStart {
8 Pending, Finished(NativeEvent)
9}
11internal fun nativeStatus(id: Long, status: Int): IoStart = if (status < 0)
12 IoStart.Finished(NativeEvent(id, IoResult.Failed(nativeStatusError(status), 0L)))
13else
14 IoStart.Pending
16internal fun nativeStatus(id: Long, status: NativeIoStatus): IoStart = if (status.code != 0)
17 IoStart.Finished(NativeEvent(id, IoResult.Failed(nativeStatusError(status), 0L)))
18else
19 IoStart.Pending
21internal fun resultFailure(
22 operation: String,
23 result: IoResult,
24 context: OsString? = None
25): Throwable? = when (result) {
26 case Failed(val error, _) ->
27 Some(
28 PlatformException(operation, error.kind, Some(error), context)
29 )
30 case _ -> None
33internal fun completionFailure(
34 operation: String,
35 result: IoResult,
36 selected: Throwable?,
37 context: OsString? = None
38): Throwable? = when (selected) {
39 case Some(_) -> selected;
40 case None -> resultFailure(operation, result, context)