Changeset 261


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

CriticalSection, CriticalSectionLockの追加

Location:
Include/Classes
Files:
4 added
2 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__
  • Include/Classes/System/misc.ab

    r223 r261  
    44#define __SYSTEM_MISC_AB__
    55
    6 #require <Classes/System/Threading/WaitHandle.ab>
     6'#require <Classes/System/Threading/WaitHandle.ab>
    77
    8 Interface IObject
    9 End Interface
     8Namespace System
    109
    1110Interface IAsyncResult
    1211    ' Properties
    13     Function AsyncState() As *IObject
    14     Function AsyncWaitHandle() As WaitHandle
    15     Function CompletedSynchronously() As BOOL
    16     Function IsCompleted() As BOOL
     12    Function AsyncState() As Object
     13    Function AsyncWaitHandle() As System.Threading.WaitHandle
     14    Function CompletedSynchronously() As Boolean
     15    Function IsCompleted() As Boolean
    1716End Interface
    1817
    1918Interface IClonable
    2019    ' Method
    21     Function Clone() As *IObject
     20    Function Clone() As Object
    2221End Interface
    2322
    2423Interface IComparable
    2524    ' Method
    26     Function CompareTo(ByRef obj As IObject) As Long
     25    Function CompareTo(obj As Object) As Long
     26End Interface
     27
     28Interface IDisposable
     29    ' Method
     30    Sub Dispose()
    2731End Interface
    2832
     
    3236End Class
    3337
     38End Namespace 'System
     39#require <Classes/System/Threading/WaitHandle.ab>
     40
    3441#endif '__SYSTEM_MISC_AB__
Note: See TracChangeset for help on using the changeset viewer.