{-# LINE 1 "GHC/IO/Handle/Lock.hsc" #-}{-# LANGUAGE CPP #-}{-# LANGUAGE InterruptibleFFI #-}{-# LANGUAGE LambdaCase #-}{-# LANGUAGE MultiWayIf #-}{-# LANGUAGE NoImplicitPrelude #-}moduleGHC.IO.Handle.Lock (FileLockingNotSupported(..),LockMode(..),hLock ,hTryLock)where{-# LINE 16 "GHC/IO/Handle/Lock.hsc" #-}importData.Bits importData.Function importForeign.C.Error importForeign.C .TypesimportGHC.IO.Exception importGHC.IO.FDimportGHC.IO.Handle.FD{-# LINE 55 "GHC/IO/Handle/Lock.hsc" #-}importData.FunctorimportGHC.BaseimportGHC.ExceptionimportGHC.IO.Handle.TypesimportGHC.Show-- | Exception thrown by 'hLock' on non-Windows platforms that don't support-- 'flock'.dataFileLockingNotSupported=FileLockingNotSupportedderivingShowinstanceExceptionFileLockingNotSupported-- | Indicates a mode in which a file should be locked.dataLockMode=SharedLock|ExclusiveLock-- | If a 'Handle' references a file descriptor, attempt to lock contents of the-- underlying file in appropriate mode. If the file is already locked in-- incompatible mode, this function blocks until the lock is established. The-- lock is automatically released upon closing a 'Handle'.---- Things to be aware of:---- 1) This function may block inside a C call. If it does, in order to be able-- to interrupt it with asynchronous exceptions and/or for other threads to-- continue working, you MUST use threaded version of the runtime system.---- 2) The implementation uses 'LockFileEx' on Windows and 'flock' otherwise,-- hence all of their caveats also apply here.---- 3) On non-Windows plaftorms that don't support 'flock' (e.g. Solaris) this-- function throws 'FileLockingNotImplemented'. We deliberately choose to not-- provide fcntl based locking instead because of its broken semantics.---- @since 4.10.0.0hLock::Handle ->LockMode ->IO ()hLockhmode=void$lockImplh"hLock"modeTrue-- | Non-blocking version of 'hLock'.---- @since 4.10.0.0hTryLock::Handle->LockMode->IOBoolhTryLockhmode=lockImplh"hTryLock"modeFalse----------------------------------------{-# LINE 103 "GHC/IO/Handle/Lock.hsc" #-}lockImpl::Handle->String->LockMode->Bool->IOBoollockImplhctxmodeblock=doFD{fdFD=fd}<-handleToFdhletflags=cmode.|.(ifblockthen0else4){-# LINE 108 "GHC/IO/Handle/Lock.hsc" #-}fix$\retry->c_flockfdflags>>=\case0->returnTrue_->getErrno>>=\errno->if|notblock&&errno==eWOULDBLOCK->returnFalse|errno==eINTR->retry|otherwise->ioException$errnoToIOErrorctxerrno(Justh)Nothingwherecmode=casemodeofSharedLock->1{-# LINE 117 "GHC/IO/Handle/Lock.hsc" #-}ExclusiveLock->2{-# LINE 118 "GHC/IO/Handle/Lock.hsc" #-}foreignimportccallinterruptible"flock"c_flock::CInt->CInt->IOCInt{-# LINE 165 "GHC/IO/Handle/Lock.hsc" #-}

AltStyle によって変換されたページ (->オリジナル) /