mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-09 22:17:33 +02:00
Allow passing function args to Cyc_init_thread
This commit is contained in:
parent
39b006b493
commit
af1be469e8
1 changed files with 14 additions and 2 deletions
16
runtime.c
16
runtime.c
|
@ -6601,7 +6601,7 @@ void *gc_alloc_pair(gc_thread_data *data, object head, object tail)
|
||||||
/**
|
/**
|
||||||
* Thread initialization function only called from within the runtime
|
* Thread initialization function only called from within the runtime
|
||||||
*/
|
*/
|
||||||
void *Cyc_init_thread(object thread_and_thunk)
|
void *Cyc_init_thread(object thread_and_thunk, int argc, object *args)
|
||||||
{
|
{
|
||||||
vector_type *t;
|
vector_type *t;
|
||||||
c_opaque_type *o;
|
c_opaque_type *o;
|
||||||
|
@ -6629,6 +6629,13 @@ void *Cyc_init_thread(object thread_and_thunk)
|
||||||
} else {
|
} else {
|
||||||
thd->gc_args[0] = &Cyc_91end_91thread_67_primitive;
|
thd->gc_args[0] = &Cyc_91end_91thread_67_primitive;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (argc > 0) {
|
||||||
|
thd->gc_num_args = argc + 1;
|
||||||
|
for (int i = 0; i < argc; i++) {
|
||||||
|
thd->gc_args[i + 1] = args[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
thd->thread_id = pthread_self();
|
thd->thread_id = pthread_self();
|
||||||
|
|
||||||
// Copy thread params from the calling thread
|
// Copy thread params from the calling thread
|
||||||
|
@ -6659,6 +6666,11 @@ void *Cyc_init_thread(object thread_and_thunk)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *_Cyc_init_thread(object thread_and_thunk)
|
||||||
|
{
|
||||||
|
return Cyc_init_thread(thread_and_thunk, 0, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Spawn a new thread to execute the given thunk
|
* Spawn a new thread to execute the given thunk
|
||||||
*/
|
*/
|
||||||
|
@ -6687,7 +6699,7 @@ to look at the lock-free structures provided by ck?
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
pthread_attr_init(&attr);
|
pthread_attr_init(&attr);
|
||||||
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
|
||||||
if (pthread_create(&thread, &attr, Cyc_init_thread, thread_and_thunk)) {
|
if (pthread_create(&thread, &attr, _Cyc_init_thread, thread_and_thunk)) {
|
||||||
fprintf(stderr, "Error creating a new thread\n");
|
fprintf(stderr, "Error creating a new thread\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue