ChugR commented on a change in pull request #760:
URL: https://github.com/apache/qpid-dispatch/pull/760#discussion_r438860724
##########
File path: src/posix/threading.c
##########
@@ -150,19 +150,38 @@ void sys_rwlock_unlock(sys_rwlock_t *lock)
struct sys_thread_t {
pthread_t thread;
+ void *(*f)(void *);
+ void *arg;
};
+static __thread sys_thread_t *_self;
+
+
+// bootstrap _self before calling main thread function
+//
+static void *_thread_init(void *arg)
+{
+ _self = (sys_thread_t *)arg;
+ return _self->f(_self->arg);
+}
+
+
sys_thread_t *sys_thread(void *(*run_function) (void *), void *arg)
{
sys_thread_t *thread = NEW(sys_thread_t);
- pthread_create(&(thread->thread), 0, run_function, arg);
+ thread->f = run_function;
+ thread->arg = arg;
+ pthread_create(&(thread->thread), 0, _thread_init, (void *)thread);
return thread;
}
-long sys_thread_id(sys_thread_t *thread) {
- return (long) thread->thread;
+
Review comment:
Is sys_thread_id() now gone? Is the address returned by sys_thread_self
now sufficient to be the "id"?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]