Commit Graph

163 Commits

Author SHA1 Message Date
WP. Yingamphol
6e8bd908da Merge branch 'odin-lang:master' into master 2025-12-07 21:45:47 +07:00
WP. Yingamphol
f873231f2e Update thread name/description truncation limits 2025-11-20 19:18:55 +07:00
Laytan Laats
71afb8e7a5 removes the darwin specific paths from thread_unix
I know I left a note there about deadlocks but it doesn't seem to happen
anymore, especially now that the test runner creates cancellation points.

Also, what was this `can_set_thread_cancel_state` for? It does not make
sense to me that it enables cancellation, and then does it again later.
With the comment it seems like it should be `.DISABLE` to first disable
and then wait for the thread to start. But even that seems weird, why
do you need to do that? I removed it.
2025-11-07 21:40:25 +01:00
gingerBill
842cfee0f3 Change Odin's LICENSE to zlib from BSD 3-clause
This change was made in order to allow things produced with Odin and using Odin's core library, to not require the LICENSE to also be distributed alongside the binary form.
2025-10-28 14:38:25 +00:00
Jeroen van Rijn
7a9ea3ee6d Further overhaul of package line comments. 2025-10-09 23:05:29 +02:00
gingerBill
9ddb93bd01 Add doc line to core:thread 2025-10-09 12:29:18 +01:00
WP. Yingamphol
ed75ab49bb Change windows Thread_Description_Length to 128 2025-09-14 13:57:49 +07:00
WP. Yingamphol
704a917355 re-added Haiku os _set_name guard 2025-08-28 09:53:53 +07:00
PePerRoNii
e4cc58d992 thread.name = name in unix 2025-08-28 09:50:25 +07:00
PePerRoNii
5ab3c1794e fixed windows api and free GetThreadName's allocation 2025-08-20 21:51:56 +07:00
PePerRoNii
8884ad01f5 added name argument description 2025-08-20 21:00:25 +07:00
WP. Yingamphol
155c03a2ee Merge branch 'odin-lang:master' into master 2025-08-20 20:18:22 +07:00
WP. Yingamphol
c164332661 Apply suggestions from code review
Improve code description

Co-authored-by: Sunagatov Denis <yyakut.ac@gmail.com>
2025-08-20 07:10:19 +07:00
Laytan Laats
25389ed086 thread: set stack size to rlimit 2025-08-02 15:22:23 +02:00
PePerRoNii
2f770ff241 check for Haiku before calling _set_name 2025-07-22 11:18:45 +07:00
PePerRoNii
3c9d05a8c6 fix tid/handle bug on macos/win 2025-07-22 11:00:49 +07:00
PePerRoNii
a357113651 thread.create et al with name parameter 2025-07-22 10:52:29 +07:00
PePerRoNii
228e2752a3 use win32.wstring_to_utf8, default to temp_allocator, guarantees proper null termination 2025-07-15 12:29:26 +07:00
PePerRoNii
8f81b8761a changed [^]u8 to cstring for netbsd, added truncate_to_byte(name,0) on name return 2025-07-15 10:55:54 +07:00
WP. Yingamphol
805c3228b8 Update core/thread/thread_unix.odin
Co-authored-by: Laytan <laytanlaats@hotmail.com>
2025-07-15 09:32:02 +07:00
WP. Yingamphol
5ffba9b222 use copy proc group instead of copy_from_string
Co-authored-by: Laytan <laytanlaats@hotmail.com>
2025-07-15 09:30:49 +07:00
WP. Yingamphol
05b769734b more spacing
Co-authored-by: Laytan <laytanlaats@hotmail.com>
2025-07-15 09:29:39 +07:00
WP. Yingamphol
08c298808b spacing
Co-authored-by: Laytan <laytanlaats@hotmail.com>
2025-07-15 09:29:10 +07:00
WP. Yingamphol
02111e7515 no #optional_allocator_error
Co-authored-by: Laytan <laytanlaats@hotmail.com>
2025-07-15 09:28:38 +07:00
PePerRoNii
d875d2d445 added set_name in thread_other 2025-07-14 21:43:28 +07:00
PePerRoNii
c07830035e fix proc and variable typos 2025-07-14 21:23:28 +07:00
PePerRoNii
8bc1ffd0df remove 'do' 2025-07-14 20:58:22 +07:00
PePerRoNii
7265782ddc remove unnecessary spaces, fix t -> thread, added more description 2025-07-14 20:39:52 +07:00
PePerRoNii
6f3cc31682 substitute sync.current_thread_id with posix.pthread_self for unix 2025-07-14 18:17:19 +07:00
PePerRoNii
b87b5431b1 substitute 'do' 2025-07-14 18:10:35 +07:00
PePerRoNii
0a3f73077e Get/Set Thread names 2025-07-14 17:23:36 +07:00
Jeroen van Rijn
4b6e375f95 Expand self_cleanup documentation. 2025-06-24 14:34:28 +02:00
Jeroen van Rijn
1903d7211e Fix early join after start. 2025-06-21 11:47:00 +02:00
Bruno Panuto
6874a4cdb0 fix: make pool_finish not hang when pool_start is not called 2025-06-16 00:28:43 -03:00
Jeroen van Rijn
74f70bfbcb Comment 2025-06-12 17:09:33 +02:00
Jeroen van Rijn
5aa377e64e Revert changes to thread_unix.odin 2025-06-12 16:36:40 +02:00
Jeroen van Rijn
59ba37f232 Remove transmute 2025-06-12 16:05:34 +02:00
Jeroen van Rijn
994b5a2a6c Remove c import 2025-06-12 16:01:31 +02:00
Jeroen van Rijn
caf41aa046 Fix #5321 2025-06-12 16:00:24 +02:00
Jeroen van Rijn
ac5f3746cf Fix #5321 2025-06-12 11:30:36 +02:00
Jeroen van Rijn
07c59cb4db Early out and propagate nil in create*
If allocation of a `^Thread` failed, `create*` now properly return `nil`,
so you can assert on that instead of calling `thread.destroy` on a null pointer, say.
2025-04-17 17:26:24 +02:00
Jeroen van Rijn
1c655b84e4 Fix #5049
Keep in mind that `thread.create` needs an allocator to be set, as it returns `^Thread`.
2025-04-17 16:53:07 +02:00
Waqar Ahmed
8a27042d24 Use a proper Queue in thread.Pool
With lots of tasks the dynamic array takes a big performance hit as its
allocating all the time on pop_front
2024-11-30 22:29:47 +05:00
Laytan Laats
cc3c9bd871 fix thread_unix for Darwin after pthread corrections in posix package
afed3ce removed the sys/unix package and moved over to sys/posix, it has
new bindings for the pthread APIs but should have been equivalent (not).

8fb7182 used `CANCEL_ENABLE :: 0`, `CANCEL_DISABLE :: 1`, `CANCEL_DEFERRED :: 0`, `CANCEL_ASYNCHRONOUS :: 1` for Darwin, while the
correct values are `1`, `0`, `2` and `0` respectively (same mistake was made for
FreeBSD in that commit).

What this meant is that the
`pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS)` was not actually
successful, but because the error wasn't checked it was assumed it was.
It also meant `pthread_setcancelstate(PTHREAD_CANCEL_ENABLE)` would
actually be setting `PTHREAD_CANCEL_DISABLE`.

The code in this PR restores the behaviour by now actually deliberately
setting `PTHREAD_CANCEL_DISABLE` and not setting
`PTHREAD_CANCEL_ASYNCHRONOUS` which was the previous behaviour that does
actually seem to work for some reason.

(I also fixed an issue in fmt where `x` would use uppercase if it was a
pointer.)
2024-10-30 15:51:56 +01:00
Laytan
afed3ce6b5 remove pthread from sys/unix and use sys/posix where used 2024-10-28 19:20:43 +01:00
Karl Zylinski
093ade0504 Merge branch 'master' into file-tags-without-comments 2024-09-17 19:36:17 +02:00
Karl Zylinski
19f0127e55 Moved all packages in core, base, vendor, tests and examples to use new #+ file tag syntax. 2024-09-14 18:27:49 +02:00
Feoramund
c3f363cfbc Fix data race when pool_stop_task is called 2024-09-09 16:19:15 -04:00
Feoramund
45da009377 Use more atomic handling of thread flags
This can prevent a data race on Linux with `Self_Cleanup`.
2024-09-09 16:19:15 -04:00
Feoramund
4d14b4257e Convert POSIX Thread to use semaphore instead
One less value to store, and it should be less of a hack too.

Semaphores will not wait around if they have the go-ahead; they depend
on an internal value being non-zero, instead of whatever was loaded when
they started waiting, which is the case with a `Cond`.
2024-09-09 16:19:14 -04:00