| 1 | -- | Timeout, implemented independently of socket timeout setting. |
| 2 | module Sound.Osc.Time.Timeout where |
| 3 | |
| 4 | import System.Timeout {- base -} |
| 5 | |
| 6 | import Sound.Osc.Packet {- hsoc -} |
| 7 | import Sound.Osc.Transport.Fd {- hosc -} |
| 8 | |
| 9 | -- | Variant of 'timeout' where time is given in fractional seconds. |
| 10 | timeout_r :: Double -> IO a -> IO (Maybe a) |
| 11 | timeout_r = timeout . floor . (* 1000000) |
| 12 | |
| 13 | -- | Variant of 'recvPacket' that implements an /n/ second 'timeout'. |
| 14 | recvPacketTimeout :: Transport t => Double -> t -> IO (Maybe (PacketOf Message)) |
| 15 | recvPacketTimeout n fd = timeout_r n (recvPacket fd) |