You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently create_thread has a Box argument: fn_: Box<dyn FnOnce() -> Option<Box<dyn Any>>>.
This allows it to be passed a closure, and to be a safe function.
A possible alternative would be to do something more like pthread_create, and have it take a raw function pointer and a raw data pointer, which would mean it would be an unsafe function. One could argue that safety isn't the highest priority at this abstraction level, because Origin in general is a low-level API that most users wouldn't use directly anyway. Most users would use this through c-scape's pthread_create or Rust's std::thread API.
The text was updated successfully, but these errors were encountered:
Change `create_thread` from taking a boxed closure to taking a function
pointer, as well as an array of pointers to be copied into the new thread
to pass to the function. This avoids the need to dynamically allocate for
a `Box`, and in particular it allows c-ward's `pthread_create` to be used
from within `malloc` implementations.
And, implement thread return values, which is simpler with the removal of
`Option<Box<dyn Any>>`.
These changes do create more work for users of the API, however it also
gives them more control.
Fixes#85.
Change `create_thread` from taking a boxed closure to taking a function
pointer, as well as an array of pointers to be copied into the new thread
to pass to the function. This avoids the need to dynamically allocate for
a `Box`, and in particular it allows c-ward's `pthread_create` to be used
from within `malloc` implementations.
And, implement thread return values, which is simpler with the removal of
`Option<Box<dyn Any>>`.
These changes do create more work for users of the API, however it also
gives them more control.
Fixes#85.
Currently
create_thread
has aBox
argument:fn_: Box<dyn FnOnce() -> Option<Box<dyn Any>>>
.This allows it to be passed a closure, and to be a safe function.
A possible alternative would be to do something more like
pthread_create
, and have it take a raw function pointer and a raw data pointer, which would mean it would be anunsafe
function. One could argue that safety isn't the highest priority at this abstraction level, because Origin in general is a low-level API that most users wouldn't use directly anyway. Most users would use this through c-scape'spthread_create
or Rust'sstd::thread
API.The text was updated successfully, but these errors were encountered: