Idris2Doc : IO.Async.Posix

IO.Async.Posix

(source)

Reexports

import public IO.Async
import public IO.Async.Loop.PollH
import public IO.Async.Loop.TimerH
import public System.Posix.File
import public System.Posix.Poll.Types
import public System.Posix.Time

Definitions

poll : Has Errno es => PollH e => FileDesc f => f -> PollEvent -> Async e es PollEvent
  Polls the file descriptor for the given events without blocking
an operating system thread.

If the file descriptor does not support polling, for instance,
because it is a regular file, this will immediately return
`ev`.

Totality: total
Visibility: export
onEvent : Has Errno es => PollH e => FileDesc f => f -> PollEvent -> Async e es a -> Async e es a
  Runs a computation after polling a file descriptor.

This allows us to read from or write to a file descriptor
without blocking an operating system thread.

Totality: total
Visibility: export
readnb : Has Errno es => PollH e => FileDesc f => f -> (0 r : Type) -> FromBuf r => Bits32 -> Async e es r
  Reads from a file descriptor without blocking.

If the descriptor corresponds to a regular file, this will just
read up to the given amount of bytes from the file. If the descriptor
corresponds to a socket or FIFO (pipe), the `O_NONBLOCK` flag of
the descriptor *must* have been set (via `addFlags` for instance).

This will then first try to read from the descriptor without
polling, and if this fails with `EAGAIN`, proper file polling is used.

Totality: total
Visibility: export
readRawNb : Has Errno es => PollH e => FileDesc f => f -> Buf -> Async e es EMBuffer
  Like `readnb` but reads data into a pre-allocated buffer.

If the descriptor corresponds to a regular file, this will just
read up to the given amount of bytes from the file. If the descriptor
corresponds to a socket or FIFO (pipe), the `O_NONBLOCK` flag of
the descriptor *must* have been set (via `addFlags` for instance).

Totality: total
Visibility: export
readPtrNB : Has Errno es => PollH e => FileDesc f => f -> (0 r : Type) -> FromPtr r => CPtr -> Async e es r
  Like `readnb` but reads data into a pre-allocated C-pointer and
converts it from there.

This is useful for re-using a (reasonably large) buffer when
streaming lots of comparably small chunks of data. Instead of
allocating a new - potentially much too large - buffer with every
read (as is the case with `readnb`), we allocate a buffer once
and copy only the bytes we actually read into an immutable
data type such as a string or byte vector.

Totality: total
Visibility: export
writenb : Has Errno es => PollH e => FileDesc f => f -> ToBuf r => r -> Async e es Bits32
  Writes to a file descriptor without blocking.

If the descriptor corresponds to a regular file, this will just
write up to the given amount of bytes to the file. If the descriptor
corresponds to a socket or FIFO (pipe), the `O_NONBLOCK` flag of
the descriptor *must* have been set (via `addFlags` for instance).

This will then first try to write to the descriptor without
polling, and if this fails with `EAGAIN`, proper file polling is used.

Totality: total
Visibility: export
fwritenb : Has Errno es => PollH e => FileDesc f => f -> ToBuf r => r -> Async e es ()
  Iteratively writes a value to a file descriptor making sure
that the whole value is written. Use this, if a single call to
`write` might not write the complete data (for instance, when
writing to a pipe or socket).


Totality: total
Visibility: export
stream : Has Errno es => PollH e => FileDesc f => f -> (0 r : Type) -> FromBuf r => Bits32 -> (r -> Async e es ()) -> Async e es ()
  Continously reads and transforms data from a file
descriptor without blocking.

Visibility: export
streamp : Has Errno es => PollH e => FileDesc f => f -> (0 r : Type) -> FromPtr r => CPtr -> (r -> Async e es ()) -> Async e es ()
  Continously reads and transforms data from a file
descriptor without blocking by loading data into a
preallocated pointer.

For very large files, this can be faster than `stream` if
the data in question can be transformed in place without allocating
additional memory. This also allows us to use a very large buffer
even in case we often only read small amounts of data.

Visibility: export
sleepTill : TimerH e => (Tm -> Clock UTC) -> Async e es ()
  Wait until the given UTC time, which is computed from the
current time.

Totality: total
Visibility: export
nextMinute : Tm -> Clock UTC
  Computes local time of the next full minute.

Totality: total
Visibility: export
nextHour : Tm -> Clock UTC
  Computes local time of the next full hour.

Totality: total
Visibility: export
nextDay : Tm -> Clock UTC
  Computes local time of 00:00:00 of the next day.

Totality: total
Visibility: export
nextYear : Tm -> Clock UTC
  Computes local time of 00:00:00 on January 1 of the next day.

Totality: total
Visibility: export
nextMonth : Tm -> Clock UTC
  Computes local time of 00:00:00 of the first day of the next month.

Totality: total
Visibility: export
nextWeek : Tm -> Clock UTC
  Computes local time of 00:00:00 of the next Sunday

Totality: total
Visibility: export