Skip to content

Commit 14583c5

Browse files
brainstormiChris Rees
authored andcommitted
OSX fix joining main tread with calling thread
This is from ninenines#11
1 parent 9fc9acb commit 14583c5

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

c_src/nif_helpers.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,10 +185,14 @@ void nif_destroy_main_thread(void* void_st)
185185
nif_thread_message* msg = nif_thread_message_alloc(NULL, NULL, NULL);
186186

187187
nif_thread_send(st, msg);
188-
enif_thread_join(st->tid, NULL);
188+
#if defined(__APPLE__) && defined(__MACH__)
189+
erl_drv_stolen_main_thread_join(st->tid, NULL);
190+
#else
191+
enif_thread_join(st->tid, NULL);
192+
#endif
189193

190-
enif_cond_destroy(st->cond);
191194
enif_mutex_destroy(st->lock);
195+
enif_cond_destroy(st->cond);
192196
enif_free(st->mailbox);
193197
enif_free(st);
194198
}

0 commit comments

Comments
 (0)