Skip to content
Draft

Next #66

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
147 commits
Select commit Hold shift + click to select a range
b847ab7
after processing an event for fd, re-arm
lePereT Oct 26, 2025
c89d84d
more consistent time usage
lePereT Oct 26, 2025
738fd18
rebuild popen on cmd/exec
lePereT Oct 30, 2025
6373857
add constants needed for future libs
lePereT Oct 30, 2025
47f92b5
Merge pull request #50 from jangala-dev/next_small_fixes
lePereT Nov 7, 2025
7e5c052
`guard` and `with_nack` first-class CML events (#51)
lePereT Nov 7, 2025
6437db0
add bracket, reworked op and top-level perform
lePereT Nov 7, 2025
05fb7f5
Merge pull request #52 from jangala-dev/next_brkt
lePereT Nov 7, 2025
64ded93
working wrap_handler + finally
lePereT Nov 9, 2025
70c12d4
Merge pull request #53 from jangala-dev/next_wrap_handler
lePereT Nov 9, 2025
ae25540
stage 1: extract fibers.runtime and make op depend on it
lePereT Nov 9, 2025
c77fa7b
stage 2: introduce a basic fibers.scope with a default root scope + t…
lePereT Nov 9, 2025
707089e
moves all fibers files into a top-level src folder
lePereT Nov 9, 2025
29f3577
adds scope-aware performer, modifies all libraries, tests and examples
lePereT Nov 9, 2025
845ad65
adds full fat scope as event, retires fibers.fiber, updates examples
lePereT Nov 11, 2025
f9ec581
Merge pull request #54 from jangala-dev/major_refact
lePereT Nov 11, 2025
9adc96c
updates channels to use on_abort for cleanup
lePereT Nov 11, 2025
4d04050
corrects waitgroup reuse bug + adds test
lePereT Nov 11, 2025
73207ca
Merge pull request #55 from jangala-dev/update_primitives
lePereT Nov 12, 2025
ad35dfd
make op.cond less eager
lePereT Nov 16, 2025
aef1228
adds constants to syscall
lePereT Nov 16, 2025
9e4e434
pcall free op
lePereT Nov 16, 2025
af8d2ae
remove the use of pcall/exception to trigger scope failure
lePereT Nov 16, 2025
7c01d99
adds coxpcall, protects core lib calls only outside scopes, prevents …
lePereT Nov 17, 2025
85a7938
small tidyups
lePereT Nov 17, 2025
ee10e66
errors on performing non-events
lePereT Nov 17, 2025
1924ab6
yes Mr Linter
lePereT Nov 17, 2025
ba83096
Merge pull request #56 from jangala-dev/update_primitives
lePereT Nov 17, 2025
e74d378
rebuild sleep_op as guarded sleep_until
lePereT Nov 17, 2025
81f4983
express finally in terms of bracket
lePereT Nov 18, 2025
c4ab47e
revert channel design
lePereT Nov 18, 2025
29eaf95
simplify and improve cond, waitgroups and layering for scopes
lePereT Nov 19, 2025
25d6603
neaten sleep
lePereT Nov 19, 2025
e82e7f0
waitgroup.lua: removes variabl shadowing
lePereT Nov 19, 2025
1b9e03b
unexports op.new_cond and revises test_scope.lua to use fibers.cond
lePereT Nov 21, 2025
5864837
op.lua: corrects documentation
lePereT Nov 21, 2025
899efc5
scope.lua: prevents failures from overwriting cancellation status
lePereT Nov 21, 2025
384edb1
sched.lua: corrects documentation
lePereT Nov 21, 2025
0080f27
timer.lua: corrects documentation + small efficiencies
lePereT Nov 21, 2025
abfaf84
extract oneshot
lePereT Nov 22, 2025
cb042e0
non-exit by default, neatened scope
lePereT Nov 22, 2025
f2df514
adds filename comment
lePereT Nov 22, 2025
6df940b
rename runtime.spawn to runtime.spawn_raw
lePereT Nov 22, 2025
062c093
add guards to prioritise cancellation
lePereT Nov 22, 2025
2a31797
preserve trailing nil responses
lePereT Nov 22, 2025
08a5711
enforce no blocking outside a fiber
lePereT Nov 22, 2025
c0b7517
prevents hard exit on scope failure
lePereT Nov 22, 2025
9f5f0ab
scope: move failure accounting into Scope:spawn and extend with_ev tests
lePereT Nov 22, 2025
8266633
initial LuaLS annotation
lePereT Nov 23, 2025
f94d60c
initial LuaLS annotation for cond.lua
lePereT Nov 23, 2025
8da4097
settle on op naming
lePereT Nov 24, 2025
5b44bc3
adds waiter abstraction and test
lePereT Nov 28, 2025
2aaa839
adds ffi + rope based ring and linear buffers
lePereT Nov 28, 2025
580fccd
adds stream absraction + mem backend built on waitable
lePereT Nov 28, 2025
2acd9a4
adds poller, fd_backend, file and socket + tests
lePereT Nov 28, 2025
2a2b5fb
adds new process abstraction
lePereT Nov 28, 2025
b41ca99
deletes old stream abstraction and switches tests
lePereT Nov 28, 2025
83fc38d
bugfix: fibers.run should now raise
lePereT Nov 28, 2025
cf2e164
removes context abstraction
lePereT Nov 28, 2025
a54512d
corrects test file
lePereT Nov 28, 2025
c291e68
timer: fix linter issues
lePereT Nov 28, 2025
519c9da
make a fiber a subtype of task
lePereT Nov 28, 2025
55b52d6
make a suspension a subtype of task
lePereT Nov 28, 2025
5e95cf7
use safe.pcall
lePereT Nov 28, 2025
a72d762
sched concision
lePereT Nov 28, 2025
c974165
reworks bytes and adds ffi_compat layer
lePereT Nov 30, 2025
698a03d
cleanly splits fd backend implementations
lePereT Nov 30, 2025
94bcd73
cleanly splits poller implementations
lePereT Nov 30, 2025
a717664
trims big fat syscall
lePereT Nov 30, 2025
712678d
deletes uneeded epoll file
lePereT Nov 30, 2025
6e1db3d
corrects and cleans up tests for previous cases
lePereT Nov 30, 2025
77a117a
corrects type annotations
lePereT Nov 30, 2025
446e5d0
moves fd and poller to new shapes
lePereT Dec 4, 2025
331fc5e
replaces process with exec
lePereT Dec 4, 2025
e56675a
makes top-level io os agnostic
lePereT Dec 6, 2025
d0301ef
removes sc time
lePereT Dec 6, 2025
3f39c7b
updates io backends, adds nixio backends
lePereT Dec 8, 2025
536270e
updates utils/time, scheduler and tests to use new time, removes unus…
lePereT Dec 8, 2025
8c4cce3
changes fibers.spawn to not pass scope first to thunk
lePereT Dec 8, 2025
58b070c
adds some initial examples
lePereT Dec 8, 2025
04f3bd8
minor spellings
lePereT Dec 8, 2025
3d86d67
new examples, docs and cleanup
lePereT Dec 8, 2025
9746eed
removes extraneous debug traceback wrap from coxpcall.pcall
lePereT Dec 8, 2025
e024fdc
updates shapes of fibers.spawn() and fibers.run_scope()/scope.run(), …
lePereT Dec 8, 2025
57f3595
reinstates all io backends
lePereT Dec 8, 2025
5087d92
goodbye syscall
lePereT Dec 8, 2025
907c9aa
updates exec with function annotation and updates tests
lePereT Dec 9, 2025
899131a
typos
lePereT Dec 10, 2025
f937855
adds core alarm facility and civil example
lePereT Dec 10, 2025
2cf2e9b
remove all traces of context
lePereT Dec 10, 2025
c2af85d
remove redundant queue
lePereT Dec 10, 2025
c2dabaa
remove redundant old stream test
lePereT Dec 10, 2025
7812c08
renames scope:done_op() to scope:not_ok_op()
lePereT Dec 10, 2025
5ec2845
revert to standard LuaJIT 2.1 and reinstate PUC Lua integration testing
lePereT Dec 11, 2025
b0cc45e
stops terrible format on save thing
lePereT Dec 12, 2025
328228b
sigh, gitignore!
lePereT Dec 12, 2025
0dd003c
goodbye scope:defer, arise scope:finally
lePereT Dec 12, 2025
46bf322
upgrade devcontainer base to Ubuntu 24.04
lePereT Dec 12, 2025
fa7e837
correct LuaLS annotations
lePereT Dec 12, 2025
225549d
corrects LuaJIT installation method
lePereT Dec 12, 2025
3e9caa0
renames finally_failures to extra_errors
lePereT Dec 12, 2025
97c58ac
adds LuaLS automatic formatting, moves to tab identation fixes all li…
lePereT Dec 13, 2025
327d947
adds Wingo and Snabb acknowledgement!
lePereT Dec 13, 2025
618b5c6
clearer comments
lePereT Dec 17, 2025
3a35c31
adds op examples
lePereT Dec 17, 2025
86f90a5
ensure that oneshots are cleaned up
lePereT Dec 17, 2025
074ce5c
improves probe randomness
lePereT Dec 17, 2025
cf7fc01
adds more complex demo
lePereT Dec 17, 2025
72c6d01
removes join fiber
lePereT Dec 18, 2025
34af7c1
join-tree guarantees, cancellation as control flow
lePereT Dec 21, 2025
ec2a9b9
don't return values at boundaries in a table
lePereT Dec 21, 2025
fa62480
ensure TB handlers are always used
lePereT Dec 21, 2025
59f9d83
rename scope:run_op to scope:try_op
lePereT Dec 21, 2025
c405efa
revise scope.lua adds run_op
lePereT Dec 21, 2025
c0517ec
neatening scope, editing examples + docs
lePereT Dec 22, 2025
fd91df4
comprehensive scope testing
lePereT Dec 22, 2025
b637170
a single op may now alternate between registering on rd and wr across…
lePereT Dec 22, 2025
0f3453a
adds mailbox primitive + tests
lePereT Dec 22, 2025
7f6c123
includes mailbox tests in suite
lePereT Dec 22, 2025
fb69436
allows detachment of finalisers
lePereT Dec 23, 2025
b9bc988
Merge pull request #57 from jangala-dev/better_scope
lePereT Jan 8, 2026
c6c48b3
Merge pull request #59 from jangala-dev/reverse-step
lePereT Jan 8, 2026
41e1a06
Merge pull request #60 from jangala-dev/mailbox
lePereT Jan 8, 2026
ee53801
moves to our own image removes pre-commit and huge python dependency
lePereT Jan 9, 2026
40752ee
finalisers as a linked list
lePereT Jan 12, 2026
a68ef27
yes Linter, sir
lePereT Jan 12, 2026
2622747
optimisation for primitive ops
lePereT Jan 13, 2026
d105d06
changes some assertions to levelled user-facing errors
lePereT Jan 13, 2026
20d4cdf
fixes regression in scopes, new finaliser boundary moved to finalisat…
lePereT Jan 13, 2026
2dcf488
neatens and tightens scopes
lePereT Jan 13, 2026
6398bb4
reworks documentation, adds a very tricky test
lePereT Jan 14, 2026
fefb032
removes fibers.try_perform in line with new documentation
lePereT Jan 14, 2026
2c4a64c
mailbox: support block/drop_newest/drop_oldest on full
lePereT Jan 14, 2026
388bebf
generalises mailbox return behaviour
lePereT Jan 16, 2026
c029db0
allows scope2:finally() to be called from scope1 if scope2 has not sp…
lePereT Jan 16, 2026
92d2255
adds pulse primitive
lePereT Jan 16, 2026
abbd5f4
safe operations on closed streams and tightened waitable
lePereT Jan 17, 2026
296453a
adds mkdir, exposes unlinkand rename, adds test
lePereT Feb 2, 2026
8528865
adds mkdir_p
lePereT Feb 2, 2026
e384801
Next stream (#61)
lePereT Feb 3, 2026
8204713
Add IPv4 socket support across backends and socket API (#62)
lePereT Feb 24, 2026
ccc5023
finaliser receives the primary reason for both failure and cancellation
lePereT May 3, 2026
7eb0542
more flexible op.choice and semantic finalisation
lePereT May 8, 2026
00e21de
replaces fifo for channels waiters with modified dlist, adds dlist te…
lePereT May 13, 2026
34675f7
actively removes stale timers (#63)
lePereT Jun 1, 2026
9517d3b
exec: correct scope finaliser detachment (#64)
lePereT Jun 4, 2026
927ab7d
Fix evented exec and long-lived scope waiter retention (#65)
lePereT Jun 18, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .devcontainer/Dockerfile

This file was deleted.

10 changes: 3 additions & 7 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"build": {
"dockerfile": "Dockerfile"
// [Optional] You can use build args to set options. e.g. 'VARIANT' below affects the image in the Dockerfile
// "args": { "VARIANT": "buster" }
},
"remoteUser": "vscode",
"postCreateCommand": "bash .devcontainer/postCreateCommand.sh",
"image": "ghcr.io/jangala-dev/mini-lua-image:bookworm",
"remoteUser": "vscode",
"postCreateCommand": "bash .devcontainer/postCreateCommand.sh",
"customizations": {
"vscode": {
"extensions": [
Expand Down
42 changes: 0 additions & 42 deletions .devcontainer/postCreateCommand.sh
Original file line number Diff line number Diff line change
@@ -1,45 +1,3 @@
#!/bin/sh

sudo apt update -y

sudo apt install -y apt-utils unzip curl wget git build-essential libreadline-dev dialog libssl-dev m4 netcat pre-commit

# install core lua packages

sudo apt install -y lua5.1 liblua5.1-dev luarocks

# install luarocks packages

sudo luarocks install bit32
sudo luarocks install cqueues
sudo luarocks install http
sudo luarocks install luaposix
sudo luarocks install luacheck

# install cffi-lua

sudo apt install -y meson pkg-config cmake libffi-dev

cd /tmp
sudo rm -rf cffi-lua
git clone https://github.com/q66/cffi-lua
mkdir cffi-lua/build
cd cffi-lua/build
sudo meson .. -Dlua_version=5.1 --buildtype=release
sudo ninja all
sudo ninja test
sudo cp cffi.so /usr/local/lib/lua/5.1/cffi.so

cd /tmp
git clone https://github.com/LuaJIT/LuaJIT
cd LuaJIT/
git checkout v2.1.ROLLING
make && sudo make install
sudo ln -sf "$(ls -1 /usr/local/bin/luajit-2.1* | sort | tail -n 1)" /usr/local/bin/luajit
cd /tmp
rm -rf LuaJIT

cd /workspaces/lua-fibers
pre-commit install

exit 0
171 changes: 171 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@

# see https://github.com/CppCXY/EmmyLuaCodeStyle
[*.lua]
# [basic]

# optional space/tab
indent_style = tab
# if indent_style is space, this is valid
indent_size = 4
# if indent_style is tab, this is valid
tab_width = 4
# none/single/double
quote_style = single

continuation_indent = 4
## extend option
# continuation_indent.before_block = 4
# continuation_indent.in_expr = 4
# continuation_indent.in_table = 4

# this mean utf8 length , if this is 'unset' then the line width is no longer checked
# this option decides when to chopdown the code
max_line_length = 120

# optional crlf/lf/cr/auto, if it is 'auto', in windows it is crlf other platforms are lf
# in neovim the value 'auto' is not a valid option, please use 'unset'
end_of_line = auto

# none/ comma / semicolon / only_kv_colon
table_separator_style = none

#optional keep/never/always/smart
trailing_table_separator = keep

# keep/remove/remove_table_only/remove_string_only
call_arg_parentheses = keep

detect_end_of_line = false

# this will check text end with new line
insert_final_newline = true

# [space]
space_around_table_field_list = true

space_before_attribute = true

space_before_function_open_parenthesis = false

space_before_function_call_open_parenthesis = false

space_before_closure_open_parenthesis = true

# optional always/only_string/only_table/none
# or true/false
space_before_function_call_single_arg = always
## extend option
## always/keep/none
# space_before_function_call_single_arg.table = always
## always/keep/none
# space_before_function_call_single_arg.string = always

space_before_open_square_bracket = false

space_inside_function_call_parentheses = false

space_inside_function_param_list_parentheses = false

space_inside_square_brackets = false

# like t[#t+1] = 1
space_around_table_append_operator = false

ignore_spaces_inside_function_call = false

# detail number or 'keep'
space_before_inline_comment = 1

# convert '---' to '--- ' or '--' to '-- '
space_after_comment_dash = false

# [operator space]
space_around_math_operator = true
# space_around_math_operator.exponent = false

space_after_comma = true

space_after_comma_in_for_statement = true

# true/false or none/always/no_space_asym
space_around_concat_operator = true

space_around_logical_operator = true

# true/false or none/always/no_space_asym
space_around_assign_operator = true

# [align]

align_call_args = false

align_function_params = true

# true/false or always
align_continuous_assign_statement = true

align_continuous_rect_table_field = true

align_continuous_line_space = 1

align_if_branch = false

# option none / always / contain_curly/
align_array_table = true

align_continuous_similar_call_args = false

align_continuous_inline_comment = true
# option none / always / only_call_stmt
align_chain_expr = none

# [indent]

never_indent_before_if_condition = false

never_indent_comment_on_if_branch = false

keep_indents_on_empty_lines = false

allow_non_indented_comments = false
# [line space]

# The following configuration supports four expressions
# keep
# fixed(n)
# min(n)
# max(n)
# for eg. min(2)

line_space_after_if_statement = max(2)

line_space_after_do_statement = max(2)

line_space_after_while_statement = max(2)

line_space_after_repeat_statement = max(2)

line_space_after_for_statement = max(2)

line_space_after_local_or_assign_statement = keep

line_space_after_function_statement = fixed(2)

line_space_after_expression_statement = keep

line_space_after_comment = keep

line_space_around_block = keep
# [line break]
break_all_list_when_line_exceed = false

auto_collapse_lines = false

break_before_braces = false

# [preference]
ignore_space_after_colon = false

remove_call_expression_list_finish_comma = false
# keep / always / same_line / replace_with_newline / never
end_statement_with_semicolon = keep
20 changes: 14 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,30 @@ on: [pull_request]

jobs:
validate-pr:
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
container:
image: ghcr.io/jangala-dev/mini-lua-image:bookworm
options: --user 0:0

steps:
- name: Check out repository
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Run custom install script
run: |
chmod +x .devcontainer/postCreateCommand.sh
./.devcontainer/postCreateCommand.sh

- name: Run luajit 2.17 Tests in Tests Directory
- name: Run lua 5.1 Tests in Tests Directory
run: |
cd tests
lua test.lua

- name: Run luajit 2.1 Tests in Tests Directory
run: |
cd tests
luajit test.lua

- name: Run Linter
run: luacheck .
# - name: Run Linter
# run: luacheck .

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*DS_Store
/scratch*
8 changes: 0 additions & 8 deletions .pre-commit-config.yaml

This file was deleted.

6 changes: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"editor.tabSize": 2,
"editor.tabSize": 4,
"editor.indentSize": "tabSize",
"editor.insertSpaces": true,
"editor.formatOnSave": true,
"editor.formatOnSave": false,
"editor.formatOnSaveMode": "modifications",
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "never"
Expand All @@ -14,4 +14,4 @@
"[lua]": {
"editor.tabSize": 4
},
}
}
Loading
Loading