From cb512c850043689c4dded4a25f77b14ff1ff4359 Mon Sep 17 00:00:00 2001 From: Mya Date: Thu, 24 Jun 2021 15:18:00 -0700 Subject: [PATCH] simplify mutex usage --- process/process.go | 5 ++--- v3/process/process.go | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/process/process.go b/process/process.go index a667ddfe..d2a043d6 100644 --- a/process/process.go +++ b/process/process.go @@ -27,7 +27,7 @@ type Process struct { name string status string parent int32 - parentMutex *sync.RWMutex // for windows ppid cache + parentMutex sync.RWMutex // for windows ppid cache numCtxSwitches *NumCtxSwitchesStat uids []int32 gids []int32 @@ -170,8 +170,7 @@ func NewProcess(pid int32) (*Process, error) { func NewProcessWithContext(ctx context.Context, pid int32) (*Process, error) { p := &Process{ - Pid: pid, - parentMutex: new(sync.RWMutex), + Pid: pid, } exists, err := PidExistsWithContext(ctx, pid) diff --git a/v3/process/process.go b/v3/process/process.go index 6dd71677..1bd3d1c6 100644 --- a/v3/process/process.go +++ b/v3/process/process.go @@ -27,7 +27,7 @@ type Process struct { name string status string parent int32 - parentMutex *sync.RWMutex // for windows ppid cache + parentMutex sync.RWMutex // for windows ppid cache numCtxSwitches *NumCtxSwitchesStat uids []int32 gids []int32 @@ -181,8 +181,7 @@ func NewProcess(pid int32) (*Process, error) { func NewProcessWithContext(ctx context.Context, pid int32) (*Process, error) { p := &Process{ - Pid: pid, - parentMutex: new(sync.RWMutex), + Pid: pid, } exists, err := PidExistsWithContext(ctx, pid)