44 Commits

Author SHA1 Message Date
gingerBill
3e7e779abf Replace core:* to base:* where appropriate 2024-01-28 22:18:51 +00:00
gingerBill
2cc22d118d Require parentheses for #align(N) 2023-08-15 14:55:02 +01:00
hikari
3b8515beb0 [core:thread] Seeing if this fixes network tests 2023-06-07 20:52:41 +03:00
hikari
7b62b81ebd [core:thread] Fix compilation 2023-06-07 20:03:19 +03:00
hikari
dcf4e51787 [core:thread] Added self_cleanup flag to properly auto-clean threads 2023-06-07 19:11:16 +03:00
Tetralux
5d6b923244 [thread] Refactor handling of 'init_context' + add doc comments for it 2023-06-03 08:08:18 +00:00
Jeroen van Rijn
f4ad4c7aa6 Disable thread.terminate on Darwin for now. 2022-05-11 16:17:35 +02:00
Jeroen van Rijn
8fb718245a Implement pthread_cancel. 2022-05-11 15:52:04 +02:00
Jeroen van Rijn
56e3b7cb7d Fix join on *nix. 2022-05-11 13:43:29 +02:00
gingerBill
4eb4ae6305 Replace sync with sync2 2022-03-30 17:42:44 +01:00
Dale Weiler
3da8fa9b27 can use sync.guard here 2022-03-11 08:41:03 -05:00
Dale Weiler
32ba5e7ad2 formatting 2022-03-11 08:36:04 -05:00
Dale Weiler
52df80dccd fix for mac & use atomic store on write side to avoid race 2022-03-11 08:35:23 -05:00
Dale Weiler
7f845bb165 fix for spurious wakeups 2022-03-11 08:30:03 -05:00
Dale Weiler
0e6de5673b fix thread data races 2022-03-11 08:06:23 -05:00
Sébastien Marie
5676c9e7eb initial OpenBSD support 2022-02-25 08:49:25 +00:00
powerc9000
2f3c5336d9 Fix mutex and conditions trying to be destroyed twice in unix 2022-01-27 15:38:16 -07:00
gingerBill
d165de0d4d Move thread initialization variables in thread_unix.odin 2021-10-26 11:46:31 +01:00
gingerBill
c9e6862332 Add id to thread.Thread 2021-10-24 12:30:25 +01:00
gingerBill
ca33cb990b Strip semicolons in core which were missing 2021-09-08 13:12:38 +01:00
gingerBill
21cbac755e Make or_else and or_return operators (binary and suffix respectively) 2021-08-15 17:14:35 +01:00
gingerBill
f7413ca974 Fix thread_unix.odin 2021-07-05 16:36:07 +01:00
gingerBill
9b3a0251ca Use or_else in the core library when it makes sense 2021-07-05 16:33:01 +01:00
gingerBill
ebed29fc09 Revert *nix thread stuff to old sync
(I was just testing)
2021-04-13 19:09:04 +01:00
gingerBill
1156bd9dd0 Remove thread stuff from sync2; Cleanup package thread 2021-04-11 18:25:56 +01:00
gingerBill
95b94a0f56 Fix sync.Channel code; add thread.run_with_poly_data and run_with_poly_data(2|3|4) procedures 2020-11-10 15:00:40 +00:00
gingerBill
fc4fdd588e Remove usage of do in core library 2020-09-23 17:17:14 +01:00
Christian Seibold
577be4a8ae Get Odin compiling and produced exe's running on FreeBSD 2020-09-14 15:22:35 -05:00
gingerBill
b2beb9512f Add thread.join_multiple 2020-07-14 21:08:04 +01:00
gingerBill
858c5f8fd8 Update thread_unix logic 2020-06-27 11:36:48 +01:00
gingerBill
0ab356aa4e Fix sync and thread on *nix 2020-06-22 13:32:58 +01:00
gingerBill
b3c51a8b44 Add thread.run* shorthand procedures; Thread.init_context use new Maybe concept 2020-06-22 13:28:37 +01:00
gingerBill
218c1599b1 Add explicit context to thread_unix.odin 2020-05-14 13:48:03 +01:00
gingerBill
b725ae5ae0 Merge pull request #617 from Tetralux/dep-yield-processor
Rename `yield_processor` to `cpu_relax`
2020-04-21 18:07:04 +01:00
Tetralux
8dd1b61aa2 sync.yield_processor -> sync.cpu_relax; have it call intrinsics.cpu_relax 2020-04-21 16:07:18 +00:00
Tetralux
d3f2f94800 Remove outdated comment
This is what I get for removing the ability to provide a stack at the last minute.... 🤣
2020-04-21 15:22:42 +01:00
KTRosenberg
d017b5de9d replaced pthread_yield with ssched_yield, fixed semaphore post:q 2020-01-02 16:25:48 -05:00
gingerBill
93ead4bcb3 Fix typo 2020-01-02 15:41:32 +00:00
gingerBill
3bd00fd6b7 Add thread.Pool with example in demo.odin; Update linalg to support handness changes for projection matrices 2020-01-02 15:07:12 +00:00
gingerBill
c407687a4c Fix new changes to runtime for unix 2019-12-31 14:04:19 +00:00
gingerBill
a8a4dc1eb1 Make default context.temp_allocator thread safe when using package thread 2019-12-29 18:08:48 +00:00
Tetralux
a3d2c40da0 whoops 2019-12-24 12:51:27 +00:00
gingerBill
cc2fa8f756 Fix thread/thread_unix.odin to use the new switch conventions 2019-12-22 12:11:54 +00:00
Tetralux
99121d6ff2 Implement core:thread and core:sync on Unix using pthreads
Also do some cleanup and refactoring of the thread, sync and time APIs.

- remove 'semaphore_release' because 'post' and 'wait' is easier to understand

- change 'semaphore_wait' to '*_wait_for' to match Condition

- pthreads can be given a stack, but doing so requires the user to set up the guard
  pages manually. BE WARNED. The alignment requirements of the stack are also
  platform-dependant; it may need to be page size aligned on some systems.
  Unclear which systems, however. See 'os.get_page_size', and 'mem.make_aligned'.
  HOWEVER: I was unable to get custom stacks with guard pages working reliably,
  so while you can do it, the API does not support it.

- add 'os.get_page_size', 'mem.make_aligned', and 'mem.new_aligned'.

- removed thread return values because windows and linux are not consistent; windows returns 'i32'
  and pthreads return 'void*'; besides which, if you really wanted to communicate how the
  thread exited, you probably wouldn't do it with the thread's exit code.

- fixed 'thread.is_done' on Windows; it didn't report true immediately after calling 'thread.join'.

- moved time related stuff out of 'core:os' to 'core:time'.

- add 'mem.align_backward'

- fixed default allocator alignment
  The heap on Windows, and calloc on Linux, both have no facility to request alignment.
  It's a bit of hack, but the heap_allocator now overallocates; `size + alignment` bytes,
  and aligns things to at least 2.
  It does both of these things to ensure that there is at least two bytes before the payload,
  which it uses to store how much padding it needed to insert in order to fulfil the alignment
  requested.

- make conditions more sane by matching the Windows behaviour.
  The fact that they were signalled now lingers until a thread tries to wait,
  causing them to just pass by uninterrupted, without sleeping or locking the
  underlying mutex, as it would otherwise need to do.
  This means that a thread no longer has to be waiting in order to be signalled, which
  avoids timing bugs that causes deadlocks that are hard to debug and fix.
  See the comment on the `sync.Condition.flag` field.

- add thread priority: `thread.create(worker_proc, .High)`
2019-12-01 00:46:23 +00:00