scoop:scoop.asyncio:0.1.0
src/event_loop.scoop
Selected production source · src/event_loop.scoop
1
package scoop.asyncio3
import scoop.time.Duration4
import scoop.platform.net.*5
import scoop.platform.system.OsString6
import scoop.platform.fs.*7
import scoop.platform.process.Command9
/**10
* The suspending filesystem, timer, resolver, TCP, UDP, and TTY service installed for a structured11
* coroutine scope. Resources and operations belong to their creating loop.12
*/13
public interface EventLoop {14
/**15
* Runs a single-use native payload on a worker and waits for completion before releasing its16
* active borrow.17
*/18
/** The active owner executor. Access before startup or after its termination is rejected. */19
public val executor: CoroutineExecutor20
/**21
* Suspends for a nonnegative duration and follows current-job cancellation.22
*/23
public suspend fun sleep(duration: Duration)24
/**25
* Schedules one owner-thread notification without creating a coroutine. None means elapsed;26
* an error reports timer failure. Disposal or current-job cancellation suppresses an unselected27
* notification. The callback does not inherit Context and must not block the owner.28
*/29
public fun schedule(duration: Duration, completion: (Throwable?) -> Unit): Disposable30
/**31
* Resolves the host and port, optionally restricted to one address family.32
*/33
public suspend fun resolve(host: OsString, port: Int, family: AddressFamily? = None): Array<34
SocketAddress35
>36
/**37
* Opens an owned asynchronous file using explicit access, creation, and truncation options.38
*/39
public suspend fun openFile(path: Path, options: OpenOptions = OpenOptions()): AsyncFile40
/**41
* Opens an owned asynchronous terminal handle.42
*/43
public suspend fun openTty(): AsyncTty44
/** Launches a child on an owned pseudoterminal using cell dimensions. */45
public suspend fun spawnPty(46
command: Command,47
columns: Long,48
rows: Long,49
searchPath: Boolean = false50
): AsyncPty51
/**52
* Queries filesystem metadata, optionally following symbolic links.53
*/54
public suspend fun metadata(path: Path, followLinks: Boolean = true): FileMetadata55
/**56
* Moves a filesystem entry, replacing the destination only when requested.57
*/58
public suspend fun moveFile(source: Path, destination: Path, replaceExisting: Boolean = false)59
/**60
* Deletes the selected filesystem entry.61
*/62
public suspend fun deleteFile(path: Path)63
/**64
* Creates missing parent directories with the requested mode, subject to the process umask.65
*/66
public suspend fun createDirectories(path: Path, mode: Int = 0x1ff)67
/**68
* Creates a unique temporary file and returns both its path and open handle.69
*/70
public suspend fun createTempFile(71
parent: Path? = None,72
prefix: String = "scoop-"73
): TemporaryFile74
/**75
* Opens an owned directory enumeration cursor.76
*/77
public suspend fun openDirectory(path: Path): AsyncDirectoryEntries78
/**79
* Binds an owned UDP socket, optionally enabling address reuse.80
*/81
public suspend fun bindUdp(82
address: SocketAddress,83
reuseAddress: Boolean = false84
): AsyncUdpSocket85
/**86
* Connects to an IP endpoint, or resolves and races candidates using the supplied host87
* connection options. The returned stream has independent ownership.88
*/89
public suspend fun connectTcp(address: SocketAddress): AsyncTcpStream90
/**91
* Connects to an IP endpoint, or resolves and races candidates using the supplied host92
* connection options. The returned stream has independent ownership.93
*/94
public suspend fun connectTcp(95
host: OsString,96
port: Int,97
options: TcpConnectOptions = tcpConnectOptions()98
): AsyncTcpStream99
/**100
* Binds and listens for TCP connections with the requested backlog and address-reuse setting.101
*/102
public suspend fun listenTcp(103
address: SocketAddress,104
backlog: Int = 128,105
reuseAddress: Boolean = false106
): AsyncTcpListener107
}