ghc-internal-9.1002.0: Basic libraries
Copyright(c) Tamar Christina 2018
LicenseBSD-style (see the file libraries/base/LICENSE)
Maintainerlibraries@haskell.org
Stabilitystable
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

GHC.Internal.Event.Windows

Description

WinIO Windows event manager.

Synopsis

Manager

data Manager Source #

The state object for the I/O manager. This structure is available for both the threaded and the non-threaded RTS.

interruptSystemManager :: IO () Source #

Interrupts an IO manager Wait. This will force the IO manager to process any outstanding events and timers. Also called when console events such as ctrl+c are used to break abort an I/O request.

wakeupIOManager :: IO () Source #

Wake up a single thread from the I/O Manager's worker queue. This will unblock a thread blocked in processCompletion and allows the I/O manager to react accordingly to changes in timers or to process console signals. No-op if the io-manager is already running.

processRemoteCompletion :: IO () Source #

Entry point for the non-threaded I/O manager to be able to process completed completions. It is mostly a wrapper around processCompletion and invoked by the C thread via the scheduler.

Overlapped I/O

associateHandle :: Manager -> HANDLE -> IO () Source #

Associate a HANDLE with the I/O manager's completion port. This must be done before using the handle with withOverlapped.

associateHandle' :: HANDLE -> IO () Source #

Associate a HANDLE with the current I/O manager's completion port. This must be done before using the handle with withOverlapped.

withOverlapped Source #

Arguments

:: String 
-> HANDLE 
-> Word64

Value to use for the OVERLAPPED structure's Offset/OffsetHigh members.

-> StartIOCallback Int 
-> CompletionCallback (IOResult a) 
-> IO (IOResult a) 

withOverlappedEx Source #

Arguments

:: Manager 
-> String

Handle name

-> HANDLE

Windows handle associated with the operation.

-> Bool 
-> Word64

Value to use for the OVERLAPPED structure's Offset/OffsetHigh members.

-> StartIOCallback Int 
-> CompletionCallback (IOResult a) 
-> IO (IOResult a) 

Start an overlapped I/O operation, and wait for its completion. If withOverlapped is interrupted by an asynchronous exception, the operation will be canceled using CancelIoEx.

withOverlapped waits for a completion to arrive before returning or throwing an exception. This means you can use functions like alloca to allocate buffers for the operation.

type StartCallback a = LPOVERLAPPED -> IO a Source #

Callback that starts the overlapped I/O operation. It must return successfully if and only if an I/O completion has been queued. Otherwise, it must throw an exception, which withOverlapped will rethrow.

type StartIOCallback a = StartCallback (CbResult a) Source #

Specialized callback type for I/O Completion Ports calls using withOverlapped.

data CbResult a Source #

CallBack result type to disambiguate between the different states an I/O Completion call could be in.

Constructors

CbDone (Maybe DWORD)

Request was handled immediately, no queue.

CbPending

Queued and to be handled by I/O manager

CbIncomplete

I/O request is incomplete but not enqueued, handle it synchronously.

CbError a

I/O request abort, return failure immediately

CbNone Bool

The caller did not do any checking, the I/O manager will perform additional checks.

Instances

Instances details
Show a => Show (CbResult a) Source # 
Instance details

Defined in GHC.Internal.Event.Windows

type CompletionCallback a Source #

Arguments

 = ErrCode

0 indicates success

-> DWORD

Number of bytes transferred

-> IO a 

Called when the completion is delivered.

type LPOVERLAPPED = Ptr OVERLAPPED Source #

Identifies an I/O operation. Used as the LPOVERLAPPED parameter for overlapped I/O functions (e.g. ReadFile, WSASend).

Timeouts

type TimeoutCallback = IO () Source #

Warning: since the TimeoutCallback is called from the I/O manager, it must not throw an exception or block for a long period of time. In particular, be wary of throwTo and killThread: if the target thread is making a foreign call, these functions will block until the call completes.

registerTimeout :: Manager -> Int -> TimeoutCallback -> IO TimeoutKey Source #

Register an action to be performed in the given number of seconds. The returned TimeoutKey can be used to later un-register or update the timeout. The timeout is automatically unregistered when it fires.

The TimeoutCallback will not be called more than once.

Be careful not to exceed maxBound :: Int, which on 32-bit machines is only 2147483647 μs, less than 36 minutes.

updateTimeout :: Manager -> TimeoutKey -> Seconds -> IO () Source #

Update an active timeout to fire in the given number of seconds (from the time updateTimeout is called), instead of when it was going to fire. This has no effect if the timeout has already fired.

Be careful not to exceed maxBound :: Int, which on 32-bit machines is only 2147483647 μs, less than 36 minutes.

unregisterTimeout :: Manager -> TimeoutKey -> IO () Source #

Unregister an active timeout. This is a harmless no-op if the timeout is already unregistered or has already fired.

Warning: the timeout callback may fire even after unregisterTimeout completes.

Utilities

withException :: String -> IO (IOResult a) -> IO a Source #

Process an IOResult and throw an exception back to the user if the action has failed, or return the result.

ioSuccess :: a -> IO (IOResult a) Source #

Signal that the I/O action was successful.

ioFailed :: Integral a => a -> IO (IOResult a) Source #

Signal that the I/O action has failed with the given reason.

ioFailedAny :: Integral a => a -> IO (IOResult b) Source #

Signal that the I/O action has failed with the given reason. Polymorphic in successful result type.

getLastError :: IO ErrCode Source #

Get the last system error produced in the current thread.

I/O Result type

data IOResult a Source #

Constructors

IOSuccess 

Fields

IOFailed 

Fields

I/O Event notifications

data HandleData Source #

Constructors

HandleData 

Fields

data HandleKey Source #

A file handle registration cookie.

Instances

Instances details
Show HandleKey Source #

Since: base-4.4.0.0

Instance details

Defined in GHC.Internal.Event.Windows

Eq HandleKey Source #

Since: base-4.4.0.0

Instance details

Defined in GHC.Internal.Event.Windows

registerHandle :: Manager -> EventCallback -> HANDLE -> Event -> Lifetime -> IO HandleKey Source #

Console events