Commit 261eddda authored by bernd's avatar bernd

Moved some tools out into another file

parent e3568a67
\ net2o tests - client side
require client-tests.fs
require test-keys.fs \ we want the test keys - never use this in production!
+db stat(
+debug
%droprate
debug-task
test-keys \ we want the test keys - never use this in production!
i'm anonymous
......
......@@ -210,7 +210,7 @@ timer: +ack
\ buffered typing
User b$
Ustack b$
: btype b$ $+! ;
: bemit b$ c$+! ;
......
......@@ -46,6 +46,7 @@ s" wrong key" throwcode !!wrong-key!!
s" no key file" throwcode !!nokey!!
s" invalid Ed25519 key" throwcode !!no-ed-key!!
s" no temporary key" throwcode !!no-tmpkey!!
s" generic stack empty" throwcode !!stack-empty!!
s" String stack full" throwcode !!string-full!!
s" String stack empty" throwcode !!string-empty!!
s" Object stack full" throwcode !!object-full!!
......
......@@ -32,9 +32,27 @@
: stack> ( stack -- x ) >r
\g generic single-stack pop
r@ $[]# dup 0<= !!object-empty!!
r@ $[]# dup 0<= !!stack-empty!!
1- dup r@ $[] @ swap cells r> $!len ;
: >stack ( x stack -- )
\g generic single-stack push
dup $[]# swap $[] ! ;
: stack@ ( stack -- x1 .. xn n )
\g fetch everything from the generic stack to the data stack
$@ dup cell/ >r bounds ?DO I @ cell +LOOP r> ;
: stack! ( x1 .. xn n stack -- )
\g set the generic stack with values from the data stack
>r cells r@ $!len
r> $@ bounds cell- swap cell- -DO I ! cell -LOOP ;
: ustack ( "name" -- )
\g generate user stack, including initialization and free on thread
\g start and termination
User latestxt >r
:noname action-of thread-init compile,
r@ compile, postpone off postpone ;
is thread-init
:noname action-of kill-task compile,
r> compile, postpone $off postpone ;
is kill-task ;
\ No newline at end of file
......@@ -18,7 +18,6 @@
\ helper words
require net2o-err.fs
require net2o-tools.fs
\ required tools
......@@ -29,6 +28,7 @@ require unix/socket.fs
require unix/mmap.fs
require unix/pthread.fs
require unix/filestat.fs
require net2o-tools.fs
require 64bit.fs
require debugging.fs
require kregion.fs
......@@ -514,27 +514,10 @@ Defer init-reply
: free-statbuf ( -- )
statbuf file-stat freez 0 to statbuf ;
User string-stack
User object-stack
User t-stack
User nest-stack
: stacks-off ( -- )
\g clear stack user variables which might have copied into
\g another task
string-stack off
object-stack off
t-stack off
nest-stack off
b$ off ;
: stacks-$off ( -- )
\g free stack user variables before freeing the task
string-stack $off
object-stack $off
t-stack $off
nest-stack $off
b$ $off ;
ustack string-stack
ustack object-stack
ustack t-stack
ustack nest-stack
: alloc-io ( -- ) \ allocate IO and reset generic user variables
-other ind-addr off reqmask off
......@@ -545,8 +528,7 @@ User nest-stack
sockaddr_in %size alloz to sockaddr1
$400 allocate throw to aligned$
init-statbuf
init-ed25519 c:init
stacks-off ;
init-ed25519 c:init ;
: free-io ( -- )
free-ed25519 c:free
......@@ -557,8 +539,7 @@ User nest-stack
init0buf maxdata 2/ mykey-salt# + $10 + freez
cmd0buf maxdata freez
inbuf free-buf
outbuf free-buf
stacks-$off ;
outbuf free-buf ;
alloc-io
......@@ -2400,7 +2381,7 @@ Variable beacons \ destinations to send beacons to
r@ .loop-err REPEAT drop rdrop ;
: create-timeout-task ( -- )
[: ." created timeout task " up@ hex. cr
[: \ ." created timeout task " up@ hex. cr
BEGIN ['] timeout-loop-nocatch catch-loop AGAIN ;]
1 net2o-task to timeout-task ;
......@@ -2415,7 +2396,7 @@ Variable beacons \ destinations to send beacons to
ELSE elit, ->request THEN ;
: create-receiver-task ( -- )
[: ." created receiver task " up@ hex. cr
[: \ ." created receiver task " up@ hex. cr
BEGIN ['] event-loop-nocatch catch-loop
( wait-task @ ?dup-IF ->timeout event> THEN ) AGAIN ;]
1 net2o-task to receiver-task ;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment