simplify mutex usage

pull/1090/head
Mya 4 years ago
parent 7ea8062810
commit cb512c8500

@ -27,7 +27,7 @@ type Process struct {
name string name string
status string status string
parent int32 parent int32
parentMutex *sync.RWMutex // for windows ppid cache parentMutex sync.RWMutex // for windows ppid cache
numCtxSwitches *NumCtxSwitchesStat numCtxSwitches *NumCtxSwitchesStat
uids []int32 uids []int32
gids []int32 gids []int32
@ -170,8 +170,7 @@ func NewProcess(pid int32) (*Process, error) {
func NewProcessWithContext(ctx context.Context, pid int32) (*Process, error) { func NewProcessWithContext(ctx context.Context, pid int32) (*Process, error) {
p := &Process{ p := &Process{
Pid: pid, Pid: pid,
parentMutex: new(sync.RWMutex),
} }
exists, err := PidExistsWithContext(ctx, pid) exists, err := PidExistsWithContext(ctx, pid)

@ -27,7 +27,7 @@ type Process struct {
name string name string
status string status string
parent int32 parent int32
parentMutex *sync.RWMutex // for windows ppid cache parentMutex sync.RWMutex // for windows ppid cache
numCtxSwitches *NumCtxSwitchesStat numCtxSwitches *NumCtxSwitchesStat
uids []int32 uids []int32
gids []int32 gids []int32
@ -181,8 +181,7 @@ func NewProcess(pid int32) (*Process, error) {
func NewProcessWithContext(ctx context.Context, pid int32) (*Process, error) { func NewProcessWithContext(ctx context.Context, pid int32) (*Process, error) {
p := &Process{ p := &Process{
Pid: pid, Pid: pid,
parentMutex: new(sync.RWMutex),
} }
exists, err := PidExistsWithContext(ctx, pid) exists, err := PidExistsWithContext(ctx, pid)

Loading…
Cancel
Save