0 | module System.Posix.Poll.Prim
5 | import System.Posix.File.Prim
7 | import public System.Posix.Poll.Struct
8 | import public System.Posix.Poll.Types
16 | %foreign "C__collect_safe:li_poll, posix-idris"
17 | prim__poll: AnyPtr -> Bits32 -> Int32 -> PrimIO CInt
27 | -> CArrayIO n PollFD
28 | -> (timeout : Int32)
29 | -> EPrim (List PollPair)
30 | poll arr timeout t =
31 | let p := unsafeUnwrap arr
32 | r # t := ffi (prim__poll p (cast n) timeout) t
36 | then E (inject $
fromNeg r) t
37 | else f1ToE1 (pollResults arr) t
41 | pollList : List PollPair -> (timeout : Int32) -> EPrim (List PollPair)
42 | pollList pairs timeout =
43 | withCArray PollFD (length pairs) $
\arr,t =>
44 | let _ # t := writeFiles arr pairs t
45 | in poll arr timeout t