a bit of experiments with semaphores for socket writing

This commit is contained in:
hyunghwan.chung 2018-04-19 15:34:25 +00:00
parent df5b9301dc
commit b4de6c7926
2 changed files with 23 additions and 12 deletions

View File

@ -331,7 +331,7 @@ class AsyncHandle(Object)
}. }.
} }
method writeBytes: bytes offset: offset length: length semaphore: sem method writeBytes: bytes offset: offset length: length signal: sem
{ {
| oldact n | | oldact n |
####################################### #######################################
@ -379,19 +379,19 @@ class AsyncHandle(Object)
self watchOutput. self watchOutput.
} }
method writeBytes: bytes semaphore: sem method writeBytes: bytes signal: sem
{ {
^self writeBytes: bytes offset: 0 length: (bytes size) semaphore: sem. ^self writeBytes: bytes offset: 0 length: (bytes size) signal: sem.
} }
method writeBytes: bytes offset: offset length: length method writeBytes: bytes offset: offset length: length
{ {
^self writeBytes: bytes offset: offset length: length semaphore: nil. ^self writeBytes: bytes offset: offset length: length signal: nil.
} }
method writeBytes: bytes method writeBytes: bytes
{ {
^self writeBytes: bytes offset: 0 length: (bytes size) semaphore: nil. ^self writeBytes: bytes offset: 0 length: (bytes size) signal: nil.
} }
} }
@ -607,20 +607,29 @@ error -> exception
if (state) if (state)
{ {
'CONNECTED NOW.............' dump. 'CONNECTED NOW.............' dump.
###sck inputTimeout: 10; outputTimeout: 10; connectTimeout: 10. ###sck inputTimeout: 10; outputTimeout: 10; connectTimeout: 10.
#############################################
write_more := [:sem | write_more := [:sem |
sck writeBytes: %[ $h, $e, $l, $l, $o, $-, $m, $o, count + 65, $o, $o, C'\n' ] semaphore: x. if (count <= 26)
if (count > 26) { count := 0 } {
else { count := count + 1 }. sck writeBytes: %[ $h, $e, $l, $l, $o, $-, $m, $o, count + 65, $o, $o, C'\n' ] signal: x.
count := count + 1.
}
else
{
System removeAsyncSemaphore: x.
}.
]. ].
x := Semaphore new. x := Semaphore new.
x signalAction: write_more. x signalAction: write_more.
System addAsyncSemaphore: x. System addAsyncSemaphore: x.
x signal.
sck outputAction: outact. ##sck outputAction: outact.
sck writeBytes: #[ $h, $e, $l, $l, $o, $-, $m, $o, $o, C'\n' ] semaphore: x. ##sck writeBytes: #[ $h, $e, $l, $l, $o, $-, $m, $o, $o, C'\n' ] signal: x.
###############################################
sck inputAction: inact. sck inputAction: inact.
sck watchInput. sck watchInput.
@ -648,6 +657,8 @@ error -> exception
newsck writeBytes: #[ $W, $e, $l, $c, $o, $m, $e, $., C'\n' ]. newsck writeBytes: #[ $W, $e, $l, $c, $o, $m, $e, $., C'\n' ].
]. ].
[ [
| s s2 st sg ss | | s s2 st sg ss |
[ [

View File

@ -8097,7 +8097,7 @@ static int compile_pragma_definition (moo_t* moo)
#endif #endif
if (is_token_word(moo, VOCA_QC)) if (is_token_word(moo, VOCA_QC))
{ {
/* #pragma qc(on). #pragma qc(off) */ /* #pragma qc(on). #pragma qc(off) - enable/disable double-quoted comments */
GET_TOKEN(moo); GET_TOKEN(moo);
if (TOKEN_TYPE(moo) != MOO_IOTOK_LPAREN) if (TOKEN_TYPE(moo) != MOO_IOTOK_LPAREN)