0 | module Postgres.DB.Wait
 1 |
 2 | import Postgres.FFI.Utility
 3 | import Postgres.Data.Conn
 4 | import Postgres.DB.Core
 5 |
 6 | %foreign cHelper "socket_wait"
 7 | prim__dbWait : Ptr PGconn -> PrimIO Int
 8 |
 9 | ||| Wait for something to happen on the given
10 | ||| connection.
11 | |||
12 | ||| NOTE: Will call to consume as a convenience
13 | |||  after finished waiting.
14 | |||
15 | ||| Returns True if waiting succeeds and False
16 | ||| if waiting fails for some reason.
17 | export
18 | pgWait : Conn -> IO Bool
19 | pgWait (MkConn conn) = do True <- (map intToBool (primIO $ prim__dbWait conn)) 
20 |                            | False => pure False
21 |                           pgConsumeInput (MkConn conn)
22 |