diff options
author | Björn-Egil Dahlberg <[email protected]> | 2010-06-07 11:25:59 +0000 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2010-06-07 11:25:59 +0000 |
commit | 9e69214f56cd5031f684da71a9eb24fa7003d1f2 (patch) | |
tree | 26446f5d6db24fc8a7246a6d637de9226fb0b9a1 /erts/emulator/beam/erl_lock_count.c | |
parent | 8f243a67b6a710b076964a7043de7adc99bfa6d5 (diff) | |
download | otp-9e69214f56cd5031f684da71a9eb24fa7003d1f2.tar.gz otp-9e69214f56cd5031f684da71a9eb24fa7003d1f2.tar.bz2 otp-9e69214f56cd5031f684da71a9eb24fa7003d1f2.zip |
Merge OTP-8681
Diffstat (limited to 'erts/emulator/beam/erl_lock_count.c')
-rw-r--r-- | erts/emulator/beam/erl_lock_count.c | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/erts/emulator/beam/erl_lock_count.c b/erts/emulator/beam/erl_lock_count.c index 0d7e1335c1..26028aeefc 100644 --- a/erts/emulator/beam/erl_lock_count.c +++ b/erts/emulator/beam/erl_lock_count.c @@ -257,6 +257,10 @@ void erts_lcnt_init() { erts_lcnt_clear_counters(); } +void erts_lcnt_late_init() { + erts_thr_install_exit_handler(erts_lcnt_thread_exit_handler); +} + /* list operations */ /* BEGIN ASSUMPTION: lcnt_data_lock taken */ @@ -570,36 +574,26 @@ void erts_lcnt_trylock(erts_lcnt_lock_t *lock, int res) { /* thread operations */ -static void *lcnt_thr_init(erts_lcnt_thread_data_t *eltd) { - void *(*function)(void *); - void *argument; - void *res; - function = eltd->function; - argument = eltd->argument; - - ethr_tsd_set(lcnt_thr_data_key, eltd); - - res = (void *)function(argument); - free(eltd); - return (void *)res; -} - - - -int erts_lcnt_thr_create(ethr_tid *tid, void * (*function)(void *), void *arg, ethr_thr_opts *opts) { +void erts_lcnt_thread_setup(void) { erts_lcnt_thread_data_t *eltd; - + lcnt_lock(); /* lock for thread id global update */ eltd = lcnt_thread_data_alloc(); lcnt_unlock(); - - eltd->function = function; - eltd->argument = arg; - - return ethr_thr_create(tid, (void *)lcnt_thr_init, (void *)eltd, opts); + ASSERT(eltd); + ethr_tsd_set(lcnt_thr_data_key, eltd); } +void erts_lcnt_thread_exit_handler() { + erts_lcnt_thread_data_t *eltd; + + eltd = ethr_tsd_get(lcnt_thr_data_key); + + if (eltd) { + free(eltd); + } +} /* bindings for bifs */ |