~amirouche/ruse-scheme-libraries

bbtree: add reference.
scheme: base: export `import`.
sxml2html: typofix.
notes: various fixes in the engine
replace hyper.dev with letloop.xyz
notes: fix build, and release
add notes and render to html with feed
Rename to ruse scheme, use license CNPLv6.
Rework/untangle (#2)

* src/arew/untangle: remove untangle- prefix...

... call/ec and escape are internal procedures, and not necessarly
specific to untangle. That is, it could be useful outside untangle.

TODO: replace UNTANGLE argument with a box.

* typofix

* src/arew/untangle: README++

* wip

* src/arew/untangle: wip untangle-channel-recv...

... Renamed untangle-channel-recv to untangle-channel-recv-one when it
takes one channel argument. What used to be untangle-channel-select,
was renamed untangle-channel-recv, because the only thing it can do is
receive from multiple channels.

untangle-channel-recv looks some what like python asyncio.wait with
that returns when FIRST_COMPLETED.

Also the argument untangle was dropped from untangle-channel-send,
untangle-channel-recv and untangle-channel-recv-one. It is supposed to
be parameter. At the moment, the code `untangle`, eventually it will
be the existing parameter called `untangled`.

* src/arew/untangle: varia

- Rename untangle-channel-recv-one to untangle-channel-recv.

- Rename and export untangle-channel-recv to untangle-channel-recv*.

- Use box-cons! to implement box-append! Mind the fact, that unlike
  append the order is not preserved. So `append` is not a good name.

- Use the parameter untangled to store the instance of <untangle>
  that runs in the current thread.

- In several procedures, make the parameter of untangle optional.

- Rename untangle-busy? to untangle-continue? (wip)

- <waiter> has only one field, other "arguments" are passed
  with the closure of resume. TODO: remove <waiter> and move
  resume to <channel>.

- TODO: `pool` does not need to be a box, instead use set!

* src/arew/untangle: rename box-append! to box-adjoin!

* src/arew/untangle: varia.

- Drop <waiter> record, and replace with resumers that are plain old
  procedures;

- Drop the box for pool and out variables, use set! instead;

- Rework both definitions of maybe-remove!? to use box procedures.
  TODO: extract that procedure to top level, to be DRY.

* typofix

* src/arew/cffi: with-lock take a list of objects.

* src/arew/entangle: typofix, and rename k to thunk.

* emacs++

* src/arew/entangle: README++

* src/arew/socket: varia

- socket-accept4: replace socket-accept with socket-accept4 that
accept a fourth flags argument that allows to specify that accepted
file descriptor must be non-blocking;

- make-socket-inet-address: create an internet socket for a given
  string IP and integer PORT.

* cleanup.

* src/arew/cffi: varia

- check: if value is -1, call error with the string representation
associated with errno.

- ftype-alloc: helper to allocate space necessary to hold a struct
(called in chez 'ftype' for foreign type), return a pointer to that
struct.

- with-foreign-free: release the memory associated with the pointer
passed as first argument.

* src/arew/untangle: add a couple of socket procedures.

- make-untangle-tcp-server-socket: create a non-blocking server socket
bound on IP and PORT;

- untangle-socket-close: close any type of socket;

- untangle-socket-connections: non-blocking (async) generator that
yields connections incoming into a server socket using socket-accept4;

- untangle-socket-generator: non-blocking byte generator;

- untangle-socket-accumulator: non-blocking bytevector accumulator.

* README++

* cosmit!

* src/arew/untangle: untangle-channel-recv*: fix race condition...

... when creating resumers. All resumers must be added to their
channel before they can be removed, since maybe-remove!?  consider a)
there is none due to race on resume procedure b) they are all
present. This patch fix case b.

* cosmit!

* src/arew/untangle: rename call/ec → call/pause, escape → pause.

* src/arew/untangle: use call/pause.

* src/arew/untangle: README++

* src/arew/concurrent-ml.scm: add it... (#3)

* src/arew/concurrent-ml.scm: add it...

... imported from fibers/operations.scm.

ref: https://github.com/wingo/fibers/tree/2a4f707827105d041668f34b62daaff871c22c07

* src/arew/untangle: add cogspace!

cogspace allow to make the code more dry, possibly faster and more
memory efficient.

✦ ❯ git diff --stat
 src/arew/untangle.scm | 245 ++++++++++++++++++++++++++--------------------------------------------
 1 file changed, 90 insertions(+), 155 deletions(-)

* src/arew/untangle: add <coop> and related basic procedures.

I like the 'coop' name. I think it is a great name for what is does:
help synchronize several threads. The rest of the names are really
confusing.

* src/arew/untangle: setup bare cogspace when there is none.

* typofix

* typofix

* src/arew/untangle: export basic coop procedures.

* src/arew/untangle: add untangle-put.
src/arew/untangle: wip
src/arew/socket: README++
src/arew/entangle: add entangle-empty?
src/arew/untangle: README++
comsit!...

... add TODO.
src/arew/entangle: rename epoll to entangle...

... TODO: extract low level epoll procedures into their own library.
src/arew/epoll: register events with a continuation.

Relying on a continuation make things cleaner in untangle.

The previous code that was returning a list of events that may or may
not be big, in any case, it required to keep track inside untangle of
what is the continuation when a file-descriptor is ready, duplicating
the work of epoll-events (that may also be big).

The new code should be better for the CPU and the RAM.
Next