source: trunk/Include/Classes/System/Threading/Semaphore.ab@ 419

Last change on this file since 419 was 419, checked in by NoWest, 16 years ago

この際なのでWaitHandle系を全部実装

File size: 2.0 KB
Line 
1' Classes/System/Threading/Semaphore.ab
2
3#ifndef __SYSTEM_THREADING_SEMAPHORE_AB__
4#define __SYSTEM_THREADING_SEMAPHORE_AB__
5
6Namespace System
7Namespace Threading
8
9Class Semaphore
10 Inherits System.Threading.WaitHandle
11
12Public
13 Sub Semaphore(initialCount As Long, maximumCount As Long)
14 This.Handle(CreateSemaphore(NULL,initialCount,maximumCount,NULL))
15 End Sub
16 Sub Semaphore(initialCount As Long, maximumCount As Long, name As String)
17 This.Handle(CreateSemaphore(NULL,initialCount,maximumCount,ToTCStr(name)))
18 End Sub
19 Sub Semaphore(initialCount As Long, maximumCount As Long, name As String, ByRef createdNew As Boolean)
20 This.Handle(CreateSemaphore(NULL,initialCount,maximumCount,ToTCStr(name)))
21 If ERROR_ALREADY_EXISTS=GetLastError() Then createdNew=False Else createdNew=True
22 'Throw ArgumentException
23 'Throw ArgumentOutOfRangeException
24 'Throw IOException
25 'Throw UnauthorizedAccessException
26 'Throw WaitHandleCannotBeOpenedException
27 End Sub
28/* Sub Semaphore(initialCount As Long, maximumCount As Long, name As String, ByRef createdNew As Boolean, semaphoreSecurity As SemaphoreSecurity)
29 TODO
30 End Sub*/
31
32 Static Function OpenExisting (name As String) As Semaphore
33 This.Handle(OpenSemaphore(SEMAPHORE_ALL_ACCESS,FALSE,ToTCStr(name)))
34 'Throw ArgumentException
35 'Throw ArgumentNullException
36 'Throw WaitHandleCannotBeOpenedException
37 'Throw IOException
38 'Throw UnauthorizedAccessException
39 End Function
40
41/* Static Function OpenExisting (String, SemaphoreRights) As Semaphore
42 TODO
43 End Function*/
44
45 Function Release() As Long
46 If ReleaseSemaphore(This.Handle(),1,Release) = 0 Then
47 'SemaphoreFullException
48 'IOException
49 'UnauthorizedAccessException
50 End If
51 End Function
52 Function Release(releaseCount As Long) As Long
53 If ReleaseSemaphore(This.Handle(),releaseCount,Release) = 0 Then
54 'ArgumentOutOfRangeException
55 'SemaphoreFullException
56 'IOException
57 'UnauthorizedAccessException
58 End If
59 End Function
60
61End Class
62
63End Namespace 'Threading
64End Namespace 'System
65
66#endif
Note: See TracBrowser for help on using the repository browser.