aded a field to hodl the total number of semaphores in SemaphoreGroup

changed await_semaphore_group() to return failure if no member semaphore exists
This commit is contained in:
hyunghwan.chung
2018-04-15 16:24:31 +00:00
parent 0d40016fa1
commit a5328db569
4 changed files with 57 additions and 33 deletions

View File

@ -612,7 +612,7 @@ error -> exception
].
[
| s s2 st sg |
| s s2 st sg ss |
[
s := Socket domain: Socket.Domain.INET type: Socket.Type.STREAM.
##s connect: (SocketAddress fromString: '127.0.0.1:9999') do: conact.
@ -624,6 +624,7 @@ error -> exception
## ###s2 listen: 10; watchInput.
## s2 listen: 10 do: accact.
(*
st := Semaphore new.
System addAsyncSemaphore: st.
System signal: st afterSecs: 5.
@ -632,16 +633,20 @@ sg := SemaphoreGroup new.
'JJJJJJJJJJJ' dump.
sg wait.
'YYYYYYYYYYYYYYY' dump.
*)
###[ while (1) { '1111' dump. System sleepForSecs: 1 } ] fork.
(*
st := Semaphore new.
System addAsyncSemaphore: st.
System signal: st afterSecs: 20.
*)
while (true)
{
if (System handleAsyncEvent isError) { break }.
ss := System handleAsyncEvent.
if (ss isError) { break }.
###if (ss == st) { System removeAsyncSemaphore: st }.
}.
]
ensure: