-
Notifications
You must be signed in to change notification settings - Fork 42
Expand file tree
/
Copy pathpriority.go
More file actions
49 lines (44 loc) · 1.22 KB
/
priority.go
File metadata and controls
49 lines (44 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package processpriority
// ProcessPriority is a universal type for process priorities. It used with the universal wrapper Set() to be platform agnostic.
type ProcessPriority int
const (
// PriorityOSSpecific is only used on Get(), it indicates that the current level is not a universal one from this package.
OSSpecific ProcessPriority = iota
Idle
BelowNormal
Normal
AboveNormal
High
RealTime
)
// String implements the fmt.Stringer interface
func (pp ProcessPriority) String() string {
switch pp {
case OSSpecific:
return "OS Specific"
case Idle:
return "Idle"
case BelowNormal:
return "Below Normal"
case Normal:
return "Normal"
case AboveNormal:
return "Above Normal"
case High:
return "High"
case RealTime:
return "Real Time"
default:
return "<unknown>"
}
}
// Set is an universal wrapper for setting process priority.
// It uses OS specific convertion and calls OS specific implementation.
func Set(pid int, priority ProcessPriority) (err error) {
return setOS(pid, priority)
}
// Get is an universal wrapper for getting process priority.
// It uses OS specific convertion and calls OS specific implementation.
func Get(pid int) (priority ProcessPriority, rawOSPriority int, err error) {
return getOS(pid)
}