ok($mthr->join() == 42, 'Main join');
ok($bthr->join() == 42, 'BEGIN join');
-# EOF
+# make sure a still-running detached thread doesn't give a warning on exit
+
+# *** add new tests above this one
+threads->create(sub { 1 while 1 })->detach();
+# *** add new tests above this one
static UV tid_counter = 0;
static IV active_threads = 0;
+static IV joinable_threads = 0;
#ifdef THREAD_CREATE_NEEDS_STACK
static IV default_stack_size = THREAD_CREATE_NEEDS_STACK;
#else
{
int veto_cleanup = 0;
MUTEX_LOCK(&create_destruct_mutex);
- if ((aTHX == PL_curinterp) && (active_threads != 1)) {
+ if ((aTHX == PL_curinterp) && (joinable_threads != 1)) {
if (ckWARN_d(WARN_THREADS)) {
- Perl_warn(aTHX_ "A thread exited while %" IVdf " threads were running", active_threads);
+ Perl_warn(aTHX_ "A thread exited while %" IVdf " threads were running", joinable_threads);
}
veto_cleanup = 1;
}
MUTEX_LOCK(&create_destruct_mutex);
active_threads--;
+ if (!cleanup) {
+ joinable_threads--;
+ }
MUTEX_UNLOCK(&create_destruct_mutex);
#ifdef WIN32
}
active_threads++;
+ joinable_threads++;
MUTEX_UNLOCK(&create_destruct_mutex);
sv_2mortal(params);
if (cleanup)
S_ithread_destruct(aTHX_ thread);
+ else {
+ MUTEX_LOCK(&create_destruct_mutex);
+ joinable_threads--;
+ MUTEX_UNLOCK(&create_destruct_mutex);
+ }
void
# endif
active_threads++;
+ joinable_threads++;
S_ithread_set(aTHX_ thread);
MUTEX_UNLOCK(&create_destruct_mutex);