Skip to content

Commit

Permalink
simplify mutex usage
Browse files Browse the repository at this point in the history
  • Loading branch information
MyaLongmire committed Jun 24, 2021
1 parent 7ea8062 commit cb512c8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions v3/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit cb512c8

Please sign in to comment.