Ignore:
Timestamp:
May 26, 2007, 1:08:15 AM (17 years ago)
Author:
イグトランス (egtra)
Message:

CriticalSection, CriticalSectionLockの追加

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Include/Classes/System/Threading/WaitHandle.ab

    r258 r261  
    44#define __SYSTEM_THREADING_WAITHANDLE_AB__
    55
    6 'Namespace System
    7 'Namespace Threading
     6#require <Classes/System/misc.ab>
     7
     8Namespace System
     9Namespace Threading
    810
    911Namespace Detail
     
    1214
    1315Class WaitHandle
     16    Inherits System.IDisposable
    1417Public
    1518    ' Properties
     
    2831
    2932    Virtual Sub ~WaitHandle()
    30         CloseHandle(h)
     33        Dispose()
    3134    End Sub
    3235
    3336    Virtual Sub Close()
    34         CloseHandle(h)
     37        Dispose()
    3538    End Sub
    3639
    37     Function WaitOne() As BOOL
     40    Override Sub Dispose()
     41        Dim hDisposing = InterlockedExchangePointer(h, 0)
     42        If hDisposing <> 0 Then
     43            CloseHandle(hDisposing)
     44        End If
     45    End Sub
     46
     47    Function WaitOne() As Boolean
    3848        Return WaitOne(INFINITE, FALSE)
    3949    End Function
    4050
    41     Function WaitOne(millisecondsTimeout As Long, exitContext As BOOL) As BOOL
     51    Function WaitOne(millisecondsTimeout As Long, exitContext As BOOL) As Boolean
    4252        Return WaitHandle.AfterWait(WaitForSingleObject(h, millisecondsTimeout As DWord), 1)
    4353    End Function
     
    6575'   Static Function WaitAny(timeout As TimeSpan, handles As *HANDLE, millisecondsTimeout As Long, exitContext As BOOL) As BOOL
    6676*/
    67     Static Function SignalAndWait(ByRef toSignal As WaitHandle, ByRef toWaitOn As WaitHandle) As BOOL
     77    Static Function SignalAndWait(toSignal As WaitHandle, toWaitOn As WaitHandle) As Boolean
    6878        Return SignalAndWait(toSignal, toWaitOn, INFINITE, FALSE)
    6979    End Function
    7080
    7181Public
    72     Static Function SignalAndWait(ByRef toSignal As WaitHandle, ByRef toWaitOn As WaitHandle, millisecondsTimeout As Long, exitContext As BOOL) As BOOL
     82    Static Function SignalAndWait(toSignal As WaitHandle, toWaitOn As WaitHandle, millisecondsTimeout As Long, exitContext As BOOL) As Boolean
    7383        Dim pSignalObjectAndWait = GetProcAddress(GetModuleHandle("Kernel32.dll"), "SignalObjectAndWait") As Detail.PFNSignalObjectAndWait
    7484        If pSignalObjectAndWait = 0 Then
     
    92102    h As HANDLE
    93103
    94     Static Function AfterWait(ret As DWord, n As DWord) As BOOL
     104    Static Function AfterWait(ret As DWord, n As DWord) As Boolean
    95105        Select Case ret
    96106            Case WAIT_TIMEOUT
    97                 Return FALSE
     107                Return False
    98108            Case WAIT_ABANDONED
    99109                ' Throw AbandonedMutexException
     
    103113            Case Else
    104114                If WAIT_OBJECT_0 <= ret And ret < WAIT_OBJECT_0 + n Then
    105                     Return TRUE
     115                    Return True
    106116                End If
    107117                ' ObjectDisposedException?
     
    112122End Class
    113123
    114 'End Namespace 'Threading
    115 'End Namespace 'System
     124End Namespace 'Threading
     125End Namespace 'System
    116126
    117127#endif '__SYSTEM_THREADING_WAITHANDLE_AB__
Note: See TracChangeset for help on using the changeset viewer.