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

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

#ifndef~#define~#endifを除去

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