1
0
mirror of https://github.com/janet-lang/janet synced 2024-10-01 08:20:40 +00:00
Commit Graph

35 Commits

Author SHA1 Message Date
Calvin Rose
2dd852da54 Use ATEND macros to add fields to abstract types.
This means we can add new properties to abstract types without
breaking old code. We can also make simple abstract types without
needing to add many NULL fields to the type.
2020-01-20 13:06:50 -06:00
Calvin Rose
f4077b678a Allow calling next on abstracts.
This will allow the creation of infinte
streams, low cost generators, etc.
2020-01-18 18:09:20 -06:00
Calvin Rose
bc2bac8cd3 Fix memory issue in allocating decode buffer.
Since the decode table is currently a single table
per thread, we just make it a thread local to avoid
issues.
2020-01-15 19:58:14 -06:00
Calvin Rose
a68ee7aac6 Update Copyright 2020. 2020-01-12 10:50:37 -06:00
Calvin Rose
6c7f376410 Try to remove potential overflow bugs.
Also make integer to size_t casts explicit rather than relying on
int32_t * sizeof(x) = size_t. This is kind of a personal preference for
this problem.
2020-01-02 22:08:17 -06:00
Calvin Rose
9dd152dc28 Add features.h for feature test macros.
Because we use an amalgated build, feature
test macros should be set in a single file that
is included before any other headers, and is placed
at the top of the amalgamated build.
2019-12-30 19:06:15 -05:00
Calvin Rose
022be217a2 Remove ==, not==, and order[<,<=,>,>=].
This unifies equality and comparison checking. Before, we had
separate functions and vm opcodes for comparing general values vs.
for comparing numbers, where the numberic functions were polymorphic and
had special cases for handling NaNs. By unfiying them, abstract types
can now better integrate with other number types and behave as keys.

For now, the old functions are aliased but will eventually be removed.
2019-12-28 16:04:15 -05:00
Calvin Rose
94246f7574 Use infinite timeout to indicate non-blocking.
Makes more sense than negative numbers.
2019-12-18 16:07:06 -05:00
Calvin Rose
07b0ef1648 Throw error on bad thread creation. 2019-12-18 15:49:57 -05:00
Calvin Rose
6a39c4b91d Pass thread body explicitly in thread/new.
Doing it via thread/send make sense, but is a bit
strange. Passing the body explicitly will make more
sense to API users.
2019-12-18 15:07:46 -05:00
Calvin Rose
f1afc5b0b4 Address #214
This adds several common patterns, which are defined in
boot.janet. This essentially gives more primitive patterns
to work with out of the box.

Fix build when JANET_REDUCED_OS is defined.
2019-12-14 20:39:14 -06:00
Calvin Rose
c3f1b54171 Update jpm path settings.
This will make it easier to use jpm as a per-project
management tool, as well as easier to set up individual
module trees.
2019-12-12 19:35:40 -06:00
Calvin Rose
9b7d642c38 Window x86 needs isnan. 2019-12-12 19:04:13 -06:00
Calvin Rose
7c2ae45809 Fix some merge issues.
Make everything compile, and test-install pass.
2019-12-12 17:14:36 -06:00
Calvin Rose
0fc36aa5d0 Signal to pending threads more often. 2019-12-12 02:19:56 -06:00
Calvin Rose
38f7e256d0 Port threads code to Windows API
Can run demo in examples/threads.janet
2019-12-10 20:32:41 -05:00
Calvin Rose
4187c972a3 Switch to multiple buffers per mailbox.
Needs less copying.
2019-12-10 13:26:00 -06:00
Calvin Rose
66d82c4513 Add mailbox capacity for back pressure.
(thread/send thread msg &opt timeout) can now timeout. Also
changed thread/self to thread/current for better consistency with
fibers, and all blocking operations will by default timeout after 1
second. I think its bad to make things block forerver by default.
2019-12-08 12:30:30 -06:00
Calvin Rose
c9c4424261 Add thread/self. 2019-12-07 17:54:08 -06:00
Calvin Rose
131733549d Get mailbox API working. 2019-12-07 16:51:00 -06:00
Calvin Rose
73f5314141 Work on moving to mailbox abstraction.
Should be more efficient in the common case.
2019-12-07 12:14:16 -06:00
Calvin Rose
0e690b4fa0 Add timeout to thread/receive.
If provided, throws an error if no message is received before
timeout. Perhaps should return nil?.
2019-12-06 09:21:36 -06:00
Calvin Rose
c804ae9f7c Update threads.c to avoid a deadlock. 2019-12-06 01:46:23 -06:00
Calvin Rose
dbcceefc20 Fix bad merge. 2019-12-04 22:41:30 -06:00
Calvin Rose
1a4035b02c Merge branch 'master' into threads-3 2019-12-04 22:39:30 -06:00
Calvin Rose
e908029392 Work on thread/receive doubling as select. 2019-12-04 22:31:01 -06:00
Calvin Rose
fd4220f254 Keep single global pthread_cond_t per thread.
This will allow thread/select to be implemented.
Also add thread/close and close method to threads.
2019-12-04 21:44:53 -06:00
Calvin Rose
de6c3d6d70 Simplify structure JanetThread and JanetChannel.
Remove JanetThreadShared.
2019-12-04 21:04:43 -06:00
Calvin Rose
474bcd50a1 Add methods to threads. 2019-12-02 04:39:13 -06:00
Calvin Rose
70c8b6838d Use make-image-dict and load-image-dict in thread/new
Rather than messing with janet_core_dictionary, we
instead cache the core enevironment, and pull out the
needed tables from there. This is more flexible, more correct, and
also exposes janet_resolve_core, which can be easily used from the C
API.
2019-12-02 04:15:22 -06:00
Calvin Rose
212479188a Have separate encode and decode dicts for threads
This is more correct and mirrors the way marshal -> unmarshal works.
2019-12-01 21:53:39 -06:00
Calvin Rose
8f31a53276 Add thread example.
Also remove reference to pthread_t in the JanetThread structure.
2019-12-01 20:47:22 -06:00
Calvin Rose
6a763aac95 Work on threads.
Add send and receive.
2019-12-01 20:28:12 -06:00
Calvin Rose
e542ba7e4d Fix amalg build. 2019-11-27 12:43:45 -06:00
Calvin Rose
bca0392738 First work on threading.
Posix only, needs to be disabled on windows. Also
the Makefile needs to be configurable, and meson.build
needs to take pthreads into account.
2019-11-26 23:13:53 -06:00