diff --git a/moo/kernel/Process.moo b/moo/kernel/Process.moo index fe7e18b..9291265 100644 --- a/moo/kernel/Process.moo +++ b/moo/kernel/Process.moo @@ -160,7 +160,11 @@ method(#class,#abstract) xxx. => method(#class) xxx { self subclassResponsibilit { | x | x := self _wait. - if (x signalAction notNil) { x signalAction value: x }. + if (x notError) + { + ## TODO: is it better to check if x is an instance of Semaphore/SemaphoreGroup? + if (x signalAction notNil) { x signalAction value: x }. + }. ^x } diff --git a/moo/kernel/Socket.moo b/moo/kernel/Socket.moo index 1c602a8..ee64ffc 100644 --- a/moo/kernel/Socket.moo +++ b/moo/kernel/Socket.moo @@ -612,7 +612,7 @@ error -> exception ]. [ - | s s2 st | + | s s2 st sg | [ s := Socket domain: Socket.Domain.INET type: Socket.Type.STREAM. ##s connect: (SocketAddress fromString: '127.0.0.1:9999') do: conact. @@ -624,13 +624,25 @@ error -> exception ## ###s2 listen: 10; watchInput. ## s2 listen: 10 do: accact. +st := Semaphore new. +System addAsyncSemaphore: st. +System signal: st afterSecs: 5. +'JJJJJJJJJJJ' dump. +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 }. }. - ] ensure: [ diff --git a/moo/lib/exec.c b/moo/lib/exec.c index 2230101..cb32588 100644 --- a/moo/lib/exec.c +++ b/moo/lib/exec.c @@ -937,11 +937,11 @@ static MOO_INLINE moo_oop_t await_semaphore_group (moo_t* moo, moo_oop_semaphore return (moo_oop_t)sem; } -/*MOO_DEBUG1 (moo, "QQQQQQQQQQQQQQQQQQQQQQQ %d\n", semgrp->sem_io_count); +MOO_DEBUG1 (moo, "QQQQQQQQQQQQQQQQQQQQQQQ %d\n", semgrp->sem_io_count); if (MOO_OOP_TO_SMOOI(semgrp->sem_io_count) <= 0) { - return MOO_ERROR_TO_OOP(MOO_EIOERR); -}*/ + //return MOO_ERROR_TO_OOP(MOO_EIOERR); +} /* no semaphores have been signaled. suspend the current process * until at least one of them is signaled */ @@ -4034,7 +4034,7 @@ static MOO_INLINE int switch_process_if_needed (moo_t* moo) /* [NOTE] no moo_pushtmp() on proc. no GC must occur * in the following line until it's used for * wake_process() below. */ - delete_from_sem_heap (moo, 0); /* moo->sem_heap_count is decremented */ + delete_from_sem_heap (moo, 0); /* moo->sem_heap_count is decremented in delete_from_sem_heap() */ /* if no process is waiting on the semaphore, * signal_semaphore() returns moo->_nil. */