Calvin Rose
617da24942
Merge pull request #726 from yumaikas/new-style-ev-bindings
...
Update ev.c to use the new binding style that provides source information
2021-07-27 20:17:19 -05:00
Andrew Owen
aabae03305
Add rselect bindings
2021-07-27 00:48:28 -06:00
Andrew Owen
7b3ab2727f
Fix copy/paste mistake in ev/take docs
2021-07-26 00:11:05 -06:00
Andrew Owen
714ba808dd
Update ev.c to use the new binding style that provides source information
2021-07-25 23:25:38 -06:00
Calvin Rose
eb84200f28
Fix linux issues with epoll on normal files.
...
We use the selfpipe trick if epoll fails with EPERM when trying to
register a file descriptor.
2021-07-25 21:47:52 -05:00
bakpakin
6f1695ecd4
Add utitities for interrupting the event loop.
...
janet_loop1_interrupt makes the event loop compatible
with safe interruptions for custom scheduling. Does this by exposing
custom events on the event loop. A custom event schedules a function pointer
to run in a way that can interrupt
epoll_wait/poll/GetQueuedCompletionStatus.
2021-07-25 09:08:46 -05:00
bakpakin
202783c67a
Add :d switch to os/spawn.
...
This allows for starting processes that can be turned into zombies.
2021-07-24 11:55:04 -05:00
Calvin Rose
f11b2c5a0d
Merge pull request #717 from yumaikas/fix-os-open-write-windows
...
Fix os open write windows, and add TerminateProcess calls
2021-07-24 07:52:40 -05:00
Andrew Owen
e8a86013da
Add fixes for :write on filestreams that come from os/open
2021-07-24 02:30:00 -06:00
Calvin Rose
e7ea39f410
Prevent possible bad garbage collection when finalizing streams.
...
The GC finalizer for streams would sometimes try and use other objects
after they had already been freed.
2021-07-20 19:42:35 -05:00
Calvin Rose
a125218d03
Move some defines.
2021-07-20 18:24:56 -05:00
Calvin Rose
aea1f59f6e
Add option to build janet without thread library.
2021-07-17 15:13:28 -05:00
Calvin Rose
1ef6db16ed
Add janet_vm_save and janet_vm_load.
...
This lets a user multiplex multiple Janet VMs on a single
thread or process if they are willing to implement context switching
themselves.
2021-07-16 20:59:03 -05:00
Calvin Rose
5defc3b914
Fix bug with ev/go when passing supervisor and value.
...
value was incorrectly set to nil in these cases. Also
fix some typos in core docstrings.
2021-06-25 18:58:19 -05:00
Calvin Rose
49f66a936c
Merge commit 'f4c9064b79d5b32fd74e5ddf25266356c22dd53b'
2021-04-29 15:58:41 -05:00
Calvin Rose
3a3003029a
Merge branch 'master' of github.com:janet-lang/janet
2021-03-26 15:44:43 -05:00
Calvin Rose
7c7ff802fa
Add net/shutdown to allow better networking with streams.
2021-03-26 15:36:25 -05:00
Andrew Chambers
f4c9064b79
Add config support for custom allocators.
2021-03-23 23:00:48 +13:00
Calvin Rose
04805d106e
Simpler overflow check.
2021-01-29 20:11:38 -06:00
Calvin Rose
af75bf3b64
Update for sending streams to new threads.
2021-01-24 16:48:46 -06:00
Calvin Rose
a2801fbef9
Fix #610 - POLLHUP should cause us to continue reading.
2021-01-23 14:26:24 -06:00
Calvin Rose
85155bb2b4
Reference #478 Update peg/compile to use dyn for default grammar.
2021-01-23 13:54:02 -06:00
Calvin Rose
317ab6df6b
Add ev/thread and ev/do-thread.
...
- Also fix setting supervisor with net/accept-loop.
2021-01-22 12:52:45 -06:00
Calvin Rose
49dcc816ae
Update os/shell to be non-blocking as well.
2021-01-18 16:44:22 -06:00
Calvin Rose
5ee6dbcdf4
Prepare for 1.14.1 release.
2021-01-18 11:43:53 -06:00
Calvin Rose
634219da2c
Fix windows swallowing IOCP events in many cases.
...
This fixes windows hanging on "failed" IO operations.
2021-01-17 20:41:59 -06:00
Calvin Rose
6dfb689d1f
Update versions to indicate 14.1
2021-01-16 15:54:27 -06:00
Calvin Rose
462e74ef87
Add os/proc-close to close all pipes associated with a subprocess.
...
This will not leak handles until the GC runs in most use cases.
2021-01-16 15:11:07 -06:00
Calvin Rose
a1cc5ca045
Fix #593 .
...
Also add ev/give-supervisor to the core.
2021-01-16 07:18:07 -06:00
Calvin Rose
4f2d1cdc00
Go back to a single supervisor channel per fiber.
...
We now also use the fiber mask to figure out which flags to wait for.
2021-01-12 21:35:28 -06:00
Calvin Rose
61cca10cf6
Allow iterating through the properties of core abstract types.
2021-01-11 23:14:07 -06:00
Calvin Rose
5e1a8c86f9
Add more network and subprocess testing with redirection.
2021-01-11 18:32:56 -06:00
Calvin Rose
bf01bf631d
More work on windows networking code.
...
Remove use of WSARecv and WSASend since for whatever reason
they seem suspect. We may want to revisit this later.
2021-01-11 18:00:31 -06:00
Calvin Rose
f0dbc2e404
Fix subprocess spawning on windows.
...
Also fix (:read stream :all)
2021-01-11 11:10:23 -06:00
Calvin Rose
4625c28e6a
Merge branch 'master' of github.com:janet-lang/janet
2021-01-10 11:59:41 -06:00
Calvin Rose
5536ba20a8
Move socket setup code from ev.c to net.c
2021-01-10 11:58:47 -06:00
Thomas Dendale
0c73c3f1cd
Minor typo in ev/rselect docstring
...
`ev/choice` is actually called `ev/select`
2021-01-10 16:42:52 +01:00
Calvin Rose
7ae7984f3c
Allow yielding from root fiber to ev loop.
2021-01-09 23:35:34 -06:00
Calvin Rose
8286b33c52
Add event-chan argument to ev/go.
...
The event-chan is the final piece of the puzzle for fibers, and
will be pushed to when a fiber yields to the event loop.
2021-01-09 23:33:23 -06:00
Calvin Rose
475775cc9d
Add a "new_channel" for root fibers.
...
When new fibers are scheduled on the event loop, this new_channel
receives the newly created fibers. This lets a fiber track which fibers
have been added and let's a user implement a supervisor.
Fix formatting.
2021-01-09 18:33:40 -06:00
Calvin Rose
444e630783
Fix formatting.
2021-01-09 10:14:20 -06:00
Calvin Rose
8951b8de7a
Inherit the supervisor channel from the root fiber if not given.
2021-01-08 16:32:23 -06:00
Calvin Rose
4e7ad3c7ce
Add initial implementation for supervisor channels.
...
Supervisor channels are a simple concept to more efficiently
enable dynamic, structure concurrency. When a top-level fiber
completes (or errors), it will push itself to it's supervisor
channel if it has one (instead of printing a stacktrace). This
let's another fiber poll a channel and "supervise" a set of fibers.
2021-01-06 23:19:22 -06:00
Calvin Rose
c357af02c2
Allow iterating over fibers with each and similar.
2021-01-03 16:17:36 -06:00
Calvin Rose
47bb7fd21b
Begin implementing async subproccesses for windows.
2021-01-03 11:21:44 -06:00
Calvin Rose
1c7ed8ca48
Use PostQueuedCompletionStatus for threaded calls on windows.
...
Ore efficient than using a self pipe.
2021-01-03 11:08:12 -06:00
Calvin Rose
61c65f3df1
Fix valgrind warning.
2020-12-31 16:30:54 -06:00
Calvin Rose
05166b3673
Fix proc getter bug.
2020-12-31 16:23:20 -06:00
Calvin Rose
0a1c93b869
Add ev api for making threaded calls.
...
Easy way to make arbitrary functions in C async.
2020-12-31 16:12:42 -06:00
Calvin Rose
788f91a36f
Remove unneeded book keeping for sub processes.
...
Since we are not using signals we no longer need some bookkeeping.
2020-12-31 11:52:12 -06:00
Calvin Rose
c831ecf5d2
Working implementation of process waiting with threads.
...
Does not require all sorts of signal handling code
that is not thread-safe and can "steal processes".
However, there is a much simpler way to add this functionality
by creating a new stream and thread for each subprocess when it is
waited on. This is perhaps _slightly_ less efficient but oh so much
simpler, since we can reuse all of our concepts from streams and there
is no need to implement a whole system around the selfpipe.
2020-12-31 11:22:18 -06:00
Calvin Rose
9e42ee153c
Merge branch 'master' into HEAD
2020-12-30 12:19:13 -06:00
Calvin Rose
ab37ee6ebb
Add :all option to ev/read.
...
Brings ev/read more in line with file/read.
2020-12-29 20:37:59 -06:00
Calvin Rose
eab5f67c5c
Fix buffer with NULL data pointer issue.
...
Simply prevent buffers from ever having a NULL data pointer.
2020-12-13 09:33:57 -06:00
Calvin Rose
aa0de01e5f
Fix some formatting and undefined behavior.
2020-12-06 14:33:08 -06:00
Calvin Rose
9d23192614
Add ev/deadline and ev/with-deadline.
...
This should be more useful than timeouts in real-world
use cases. The deadline system is based on fibers and is target
to much more coarse-grained (and therfor reliable) timeouts than things
like ev/sleep and timeout arguments.
2020-12-05 10:32:34 -06:00
Calvin Rose
cbdea8f331
Make os/execute cooperate with ev module.
...
os/execute, os/proc-wait do not block (currently posix only).
This uses the self-pipe trick to turn signals into a pollable entity.
2020-11-29 15:36:21 -06:00
Calvin Rose
a0964d44d5
Fix some valgrind errors.
...
A null pointer dereference and a memory leak with the line/col mapping.
2020-11-27 12:21:23 -06:00
Calvin Rose
ca7c5b8b10
ev/call uses current env as prototype of environment.
2020-11-26 21:13:41 -06:00
Calvin Rose
6c43489fb2
Fix #508 - nil fiber environment.
...
run-context did not handle a nil environment well, so that was fixed
and ev/call inherits the environment when creating the fiber.
2020-11-26 19:04:45 -06:00
Calvin Rose
a3e812b86d
Fix #505 - bat int64 parsing.
...
Fixes an off-by-1 error.
Also makes windows testing hopefully a bit less flaky.
2020-11-25 09:45:46 -06:00
Calvin Rose
a3f98091c4
Fix #509
...
janet_fiber returns NULL if there is a bad arity, check that before
continuing.
2020-11-23 15:28:28 -06:00
Calvin Rose
53aa19a916
Several changes to move pipe creation back into ev.c
2020-11-18 10:53:36 -06:00
Calvin Rose
cff52ded58
Add JANET_ASYNC_EVENT_CANCEL
...
also fix bug that could cause event loop to hang.
2020-11-16 18:46:59 -06:00
Calvin Rose
078f50d45a
When reading from a stream, EPIPE is considered EOS.
...
Before, EPIPE caused an error, but in most cases it is better
to consider it an end of stream. In the future, we may want to allow
cusomtization of this behavior with flags on the stream but for now
let's keep it simpler.
2020-11-16 16:49:27 -06:00
Calvin Rose
9ec5689d6b
Don't use gcroot/unroot for tracking IO operations.
...
This could have bad effects in higher load situations, and
duplicates code. It is better to keep a dedicated list of
scheduled IO operations which can be efficiently added and
removed from. It also provides and easy way to enumerate
scheduled IO operations.
2020-11-16 09:30:04 -06:00
Calvin Rose
a25b030e36
Fix EPOLL implementation.
2020-11-15 19:40:47 -06:00
Calvin Rose
d7af4596e1
Move math.h include out of windows ifdef
2020-11-15 10:21:37 -06:00
Calvin Rose
a7ed3dea4b
Remove some flags in os/open.
2020-11-15 10:06:20 -06:00
Calvin Rose
cdcb774dc8
Add os/pipe and os/open.
...
ev/pipe -> os/pipe, and os/open is a wrapper
around the open system call.
2020-11-15 09:57:29 -06:00
Calvin Rose
d199c817dc
Broken Pipe error on windows should just be end of stream.
2020-11-14 16:03:51 -06:00
Calvin Rose
139e3fab25
Invert status check for (Read/Write)File
2020-11-14 15:52:01 -06:00
Calvin Rose
7a98f9aa02
Improve windows error messages on write failures.
2020-11-14 15:48:21 -06:00
Calvin Rose
b53dd67e74
Use custom pipe implementation for overlapped io.
2020-11-14 15:44:19 -06:00
Calvin Rose
d50c4ef6da
Try again for windows build.
2020-11-14 15:01:52 -06:00
Calvin Rose
7d0b1955a2
typo
2020-11-14 14:55:26 -06:00
Calvin Rose
16cf7681f0
Fix some windows issues.
2020-11-14 14:40:39 -06:00
Calvin Rose
12f09ad2d7
Add ev/pipe and move stream code into ev.c
...
Also adds a lot to the C API and changes things up.
2020-11-14 14:29:11 -06:00
Calvin Rose
b3e88a8d80
Move read/write functions into ev.c from net.c
...
This code can also be used for non-network streams.
2020-11-14 11:48:23 -06:00
Calvin Rose
caa6576719
Fix formatting.
2020-11-11 15:35:44 -06:00
Calvin Rose
56b1ea3726
Include math.h to fix some bugs on 32 bit windows.
2020-11-08 19:06:35 -06:00
Calvin Rose
d6391f2d70
Get windows IOCP working for accept.
...
This also changes the api of servers slightly -
in light of having support for ev tasks, it is probably better
to remove the "simple" server code and replace it with some Janet
or remove it all together. While convenient, it has issues with error
handling and rigidity.
2020-11-08 18:56:13 -06:00
Calvin Rose
07910272e2
Get socket reads and writes working with IOCP.
2020-11-08 10:38:28 -06:00
Calvin Rose
8942e348bd
Small change to windows ev.
2020-11-02 08:27:45 -06:00
Calvin Rose
9f27336827
Update windows ev code.
2020-11-02 08:19:53 -06:00
Calvin Rose
88c1cf3ee7
Reformat files.
2020-10-11 09:33:07 -05:00
Calvin Rose
813e3fdcfd
Merge branch 'windows-ev' into ev
2020-10-11 09:32:17 -05:00
Calvin Rose
cb4903fa86
Overhaul of poll loop, redo ev/select.
2020-10-11 09:14:14 -05:00
Calvin Rose
964a800d51
More work on windows event loop code.
2020-10-06 19:07:29 -05:00
Calvin Rose
2e944931b3
Update timestamp function to work on windows.
2020-10-04 15:18:31 -05:00
Calvin Rose
db67538311
Work on getting ev support on windows.
2020-10-04 12:46:15 -05:00
Calvin Rose
191d0001f4
Add header on BSDs.
2020-09-07 15:22:18 -05:00
Calvin Rose
1a04ce33f1
Conditionally include epoll headers.
2020-09-07 13:13:28 -05:00
Calvin Rose
babfe50550
Merge branch 'master' into ev
...
Also add poll implementation for ev.
2020-09-07 12:52:50 -05:00
Calvin Rose
86e00e865e
Merge branch 'master' into ev
2020-08-23 11:25:04 -05:00
Calvin Rose
30522bbf7d
Merge branch 'master' into ev
2020-08-16 17:52:36 -05:00
Calvin Rose
fb26c9b2c4
Add ev/select and ev/rselect initial implementation.
...
Getting closer to a CSP implmententation. Probably
useful to move scheduling fields outside of fibers
and into an external table.
2020-08-09 00:20:27 -05:00
Calvin Rose
78ffb63429
Disallow mutlitple state machines waiting for a single fiber.
...
A 'select' operator will be channel based, not state machine based.
2020-08-08 07:51:46 -05:00
Calvin Rose
cb898fabf4
Set default channel size to 0.
2020-08-03 07:57:02 -05:00
Calvin Rose
742c5bb639
Use a common queue implementation.
...
Queues occur in three places, so we use a single
implementation rather than three separate ones. This also
has the result that janet_vm_spawn will not overflow in the case
of channel-heavy, IO-light operation.
2020-08-01 14:20:58 -05:00