diff options
author | Rickard Green <[email protected]> | 2017-01-19 16:28:35 +0100 |
---|---|---|
committer | Rickard Green <[email protected]> | 2017-01-19 16:29:03 +0100 |
commit | 6bebb90f7c94e1aa95aff06fc5c40dd07696edc2 (patch) | |
tree | b28313822a33de084b6878b2ef2fdaba3a52539a /erts/emulator | |
parent | 13345520e4e716856356367f1176530d11c92eda (diff) | |
download | otp-6bebb90f7c94e1aa95aff06fc5c40dd07696edc2.tar.gz otp-6bebb90f7c94e1aa95aff06fc5c40dd07696edc2.tar.bz2 otp-6bebb90f7c94e1aa95aff06fc5c40dd07696edc2.zip |
Introduce erts_proc_lookup_inc_refc()
Diffstat (limited to 'erts/emulator')
-rw-r--r-- | erts/emulator/beam/erl_process_lock.c | 35 | ||||
-rw-r--r-- | erts/emulator/beam/erl_process_lock.h | 2 |
2 files changed, 37 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_process_lock.c b/erts/emulator/beam/erl_process_lock.c index 180df229eb..a93f1755c8 100644 --- a/erts/emulator/beam/erl_process_lock.c +++ b/erts/emulator/beam/erl_process_lock.c @@ -1006,6 +1006,41 @@ erts_pid2proc_opt(Process *c_p, return proc; } +static ERTS_INLINE +Process *proc_lookup_inc_refc(Eterm pid, int allow_exit) +{ + Process *proc; +#ifdef ERTS_SMP + ErtsThrPrgrDelayHandle dhndl; + + dhndl = erts_thr_progress_unmanaged_delay(); +#endif + + proc = erts_proc_lookup_raw(pid); + if (proc) { + if (!allow_exit && ERTS_PROC_IS_EXITING(proc)) + proc = NULL; + else + erts_proc_inc_refc(proc); + } + +#ifdef ERTS_SMP + erts_thr_progress_unmanaged_continue(dhndl); +#endif + + return proc; +} + +Process *erts_proc_lookup_inc_refc(Eterm pid) +{ + return proc_lookup_inc_refc(pid, 0); +} + +Process *erts_proc_lookup_raw_inc_refc(Eterm pid) +{ + return proc_lookup_inc_refc(pid, 1); +} + void erts_proc_lock_init(Process *p) { diff --git a/erts/emulator/beam/erl_process_lock.h b/erts/emulator/beam/erl_process_lock.h index 2cccf0697a..773529384f 100644 --- a/erts/emulator/beam/erl_process_lock.h +++ b/erts/emulator/beam/erl_process_lock.h @@ -940,6 +940,8 @@ void erts_proc_safelock(Process *a_proc, #define erts_pid2proc(PROC, HL, PID, NL) \ erts_pid2proc_opt((PROC), (HL), (PID), (NL), 0) +Process *erts_proc_lookup_inc_refc(Eterm pid); +Process *erts_proc_lookup_raw_inc_refc(Eterm pid); ERTS_GLB_INLINE Process *erts_pix2proc(int ix); ERTS_GLB_INLINE Process *erts_proc_lookup_raw(Eterm pid); |