Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

threadWaitRead does not work on windows. #29

Merged
merged 1 commit into from
Jan 25, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/Hasql/Notifications.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ module Hasql.Notifications
FatalError (..),
)
where

import Control.Concurrent (threadDelay, threadWaitRead)
#if defined(mingw32_HOST_OS)
import Control.Concurrent ( threadDelay )
#else
import Control.Concurrent (threadWaitRead, threadDelay)
#endif
import Control.Exception (Exception, throw)
import Control.Monad (forever, unless, void, when)
import Data.ByteString.Char8 (ByteString)
Expand Down Expand Up @@ -190,9 +193,13 @@ waitForNotifications sendNotification con =
mfd <- PQ.socket pqCon
case mfd of
Nothing -> void $ threadDelay 1000000
#if defined(mingw32_HOST_OS)
Just _ -> do
void $ threadDelay 1000000
#else
Just fd -> do
void $ threadWaitRead fd

#endif
result <- PQ.consumeInput pqCon
unless result $ do
mError <- PQ.errorMessage pqCon
Expand Down
Loading