added some experimental code

This commit is contained in:
hyunghwan.chung 2018-04-13 10:14:12 +00:00
parent 7b114e3b27
commit 0d40016fa1
3 changed files with 23 additions and 7 deletions

View File

@ -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
}

View File

@ -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:
[

View File

@ -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. */