Skip to content

Commit 71f8ebd

Browse files
committed
comments
1 parent 3f5b64d commit 71f8ebd

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

inst/include/tthread/tinythread.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,13 +874,13 @@ inline void * thread::wrapper_function(void * aArg)
874874

875875
// On POSIX, we allow the thread to be joined even after execution has finished.
876876
// This is necessary to ensure that thread-local memory can be cleaned up.
877-
//
878-
// The thread is responsible for freeing the startup information
879877
#if defined(_TTHREAD_WIN32_)
880878
ti->mThread->mJoinable = false;
881879
#endif
882880

881+
// The thread is responsible for freeing the startup information
883882
delete ti;
883+
884884
return 0;
885885
}
886886

@@ -932,6 +932,12 @@ inline void thread::join()
932932
#elif defined(_TTHREAD_POSIX_)
933933
pthread_join(mHandle, NULL);
934934
#endif
935+
936+
// https://linux.die.net/man/3/pthread_join states:
937+
//
938+
// Joining with a thread that has previously been joined results in undefined behavior.
939+
//
940+
// We just allow a thread to be joined once.
935941
mJoinable = false;
936942
}
937943
}

0 commit comments

Comments
 (0)