attempted to fix wrong IO semaphore handling over a semaphore group

This commit is contained in:
hyunghwan.chung
2017-10-31 07:13:22 +00:00
parent 9ae1b99b43
commit 5ae166c1d4
7 changed files with 141 additions and 31 deletions

View File

@ -196,7 +196,8 @@ class SemaphoreGroup(Object)
first_sem := nil,
last_sem := nil,
first_sigsem := nil,
last_sigsem := nil.
last_sigsem := nil,
sem_io_count := 0.
(* TODO: good idea to a shortcut way to prohibit a certain method in the heirarchy chain?
method(#class,#prohibited) new.
@ -220,12 +221,22 @@ method(#class,#abstract) xxx. => method(#class) xxx { self subclassResponsibilit
if (x isError) { thisProcess primError dump. Exception signal: ('Cannot add a semaphore - ' & thisProcess primError) }.
^x
}
method removeSemaphore: sem
{
| x |
x := self _removeSemaphore: sem.
if (x isError) { thisProcess primError dump. Exception signal: ('Cannot remove a semaphore - ' & thisProcess primError) }.
^x
}
method wait
{
| r |
r := self _wait.
if (r signalAction notNil) { r signalAction value: r }.
^r
| x |
x := self _wait.
if (x isError) { thisProcess primError dump. Exception signal: ('Cannot remove a semaphore - ' & thisProcess primError) }.
if (x signalAction notNil) { x signalAction value: x }.
^x
}
method waitWithTimeout: seconds
@ -238,7 +249,7 @@ method(#class,#abstract) xxx. => method(#class) xxx { self subclassResponsibilit
## grant the partial membership to the internal semaphore.
## it's partial because it's not added to self.semarr.
##s _group: self.
self _addSemaphore: s.
self addSemaphore: s.
## arrange the processor to notify upon timeout.
Processor signal: s after: seconds.
@ -253,7 +264,7 @@ method(#class,#abstract) xxx. => method(#class) xxx { self subclassResponsibilit
## nullify the membership
##s _group: nil.
self _removeSemaphore: s.
self removeSemaphore: s.
## cancel the notification arrangement in case it didn't time out.
Processor unsignal: s.