source: trunk/ab5.0/ablib/src/Classes/System/Threading/EventWaitHandle.ab@ 664

Last change on this file since 664 was 599, checked in by イグトランス (egtra), 16 years ago

ThreadPoolの実装、WaitHandle.WaitAny/WaitAllのまともな実装、ほか。

File size: 2.7 KB
RevLine 
[419]1' Classes/System/Threading/EventWaitHandle.ab
[417]2
3NameSpace System
4NameSpace Threading
5
6Enum EventResetMode
7 AutoReset = False
8 ManualReset = True
9End Enum
10
11Class EventWaitHandle
12 Inherits System.Threading.WaitHandle
[599]13Private
14 Sub EventWaitHandle()
15 End Sub
[417]16Public
17 Sub EventWaitHandle (initialState As Boolean, mode As EventResetMode)
[419]18 This.Handle(CreateEvent(NULL,mode As BOOL,initialState As BOOL,NULL))
[417]19 End Sub
20 Sub EventWaitHandle (initialState As Boolean, mode As EventResetMode, name As String)
[419]21 This.Handle(CreateEvent(NULL,mode As BOOL,initialState As BOOL,ToTCStr(name)))
[417]22 End Sub
23 Sub EventWaitHandle (initialState As Boolean, mode As EventResetMode, name As String, ByRef createdNew As Boolean)
[419]24 This.Handle(CreateEvent(NULL,mode As BOOL,initialState As BOOL,ToTCStr(name)))
25 If ERROR_ALREADY_EXISTS=GetLastError() Then createdNew=False Else createdNew=True
[417]26 End Sub
27/* Sub EventWaitHandle (initialState As Boolean, mode As EventResetMode, name As String, ByRef createdNew As Boolean, EventWaitHandleSecurity)
28 TODO
29 End Sub*/
30
31/*
32WaitHandle で保持されているすべてのリソースを解放します。
33WaitHandleから継承
34Virtual Sub Close()
35End Sub
36*/
37
38/*CreateObjRef*/
39
40/*
41WaitHandleから継承
42 Virtual Sub Dispose()
43 End Sub
44*/
45
46/*Equals*/
47/*Finalize*/
48/*GetAccessControl*/
49/*GetHashCode*/
50/*GetLifetimeService*/
51/*InitializeLifetimeService*/
52/*MemberwiseClone*/
53
54
55 /*
56 既存の名前付き同期イベントを開きます。
57 */
[599]58 Static Function OpenExisting(name As String) As EventWaitHandle
59 If ActiveBasic.IsNothing(name) Then
60 Throw New ArgumentNullException("name")
61 Else If name.Length = 0 Then
62 Throw New ArgumentException("name")
63 End If
64 OpenExisting = New EventWaitHandle
65 Dim h = OpenEvent(EVENT_ALL_ACCESS, FALSE, ToTCStr(name))
66 If h = 0 Then
67 IO.Detail.ThrowWinLastErrorIOException("OpenEvent failed.")
68 End If
69 OpenExisting.Handle = h
[417]70 End Function
71
72 /*
73 セキリティアクセスを指定して既存の名前付き同期イベントを開きます。
74 */
75/* Static Function OpenExisting(name As String, rights As EventWaitHandleRights) As WaitHandle
76 TODO
77 End Function*/
78
79 /*
80 イベントの状態を非シグナル状態に設定し、スレッドをブロックします。
81 */
82 Function Reset() As Boolean
83 If ResetEvent(This.Handle()) Then Return True
84 Reset=False
85 End Function
86
87
88 /*
89 イベントの状態をシグナル状態に設定し、待機している 1 つ以上のスレッドが進行できるようにします。
90 */
91 Function Set() As Boolean
92 If SetEvent(This.Handle()) Then Return True
93 Set=False
94 End Function
95
96/*SetAccessControl*/
97/*ToString*/
98
99/*
100WaitHandleから継承
101WaitAll
102WaitAny
103WaitOne
104*/
105
106/*
107WaitHandle から継承
108Handle
[599]109SafeWaitHandle
[417]110*/
111
112End Class
113
114End Namespace
[419]115End Namespace
Note: See TracBrowser for help on using the repository browser.