// SetPriority sets the Priority field's value.
343538
func (s *GCMMessage) SetPriority(v string) *GCMMessage {
	s.Priority = &v
	return s
}
887673
func (pq *priorityQueue) peakTopPriority() (int64, error) {
	if len(*pq) > 0 {
		return (*pq)[0].priority, nil
	} else {
		return -1, fmt.Errorf("PriorityQueue is empty.  No top priority.")
	}
}
386750
func (cl *CommandList) SetPriorityID(priority, id int) {
	cl.cmdQ.PushBack(&command{fmt.Sprintf("prioid %d %d", priority, id), nil, cmdNoReturn})
}
410870
func (s *AwsSecurityFinding) SetSeverity(v *Severity) *AwsSecurityFinding {
	s.Severity = v
	return s
}
992281
func (cl *CommandList) SetPriority(priority, start, end int) error {
	if start < 0 {
		return errors.New("negative start index")
	}
	if end < 0 {
		cl.cmdQ.PushBack(&command{fmt.Sprintf("prio %d %d", priority, start), nil, cmdNoReturn})
	} else {
		cl.cmdQ.PushBack(&command{fmt.Sprintf("prio %d %d:%d", priority, start, end), nil, cmdNoReturn})
	}
	return nil
}
354237
func (d *DockerLogParser) parsePriority(line []byte) (Priority, int, error) {
	cursor := 0
	pri := d.newPriority(0)
	if len(line) <= 0 {
		return pri, cursor, ErrPriorityEmpty
	}
	if line[cursor] != PRI_PART_START {
		return pri, cursor, ErrPriorityNoStart
	}
	i := 1
	priDigit := 0
	for i < len(line) {
		if i >= 5 {
			return pri, cursor, ErrPriorityTooLong
		}
		c := line[i]
		if c == PRI_PART_END {
			if i == 1 {
				return pri, cursor, ErrPriorityTooShort
			}
			cursor = i + 1
			return d.newPriority(priDigit), cursor, nil
		}
		if d.isDigit(c) {
			v, e := strconv.Atoi(string(c))
			if e != nil {
				return pri, cursor, e
			}
			priDigit = (priDigit * 10) + v
		} else {
			return pri, cursor, ErrPriorityNonDigit
		}
		i++
	}
	return pri, cursor, ErrPriorityNoEnd
}
110196
func (p *PriorityQueue) UpdatePriority(x interface{}, newPriority float64) {
	item, ok := p.lookup[x]
	if !ok {
		return
	}

	item.priority = newPriority
	heap.Fix(p.itemHeap, item.index)
}
190675
func (s *RegisterTaskWithMaintenanceWindowInput) SetPriority(v int64) *RegisterTaskWithMaintenanceWindowInput {
	s.Priority = &v
	return s
}
364839
func (g *GroupComposer) SetPriority(l level.Priority) error {
	if l == level.Invalid {
		return fmt.Errorf("cannot set priority to an invalid setting")
	}

	for _, m := range g.messages {
		if m == nil {
			continue
		}

		if m.Priority() == level.Invalid {
			_ = m.SetPriority(l)
		}
	}

	return nil
}
472650
func SetLowPriority() error {
	// Process zero is "self", niceness value 9 is something between 0
	// (default) and 19 (worst priority). But then, this is Linux, so of
	// course we get this to take care of as well:
	//
	// "C library/kernel differences
	//
	// Within  the  kernel,  nice  values are actually represented using the
	// range 40..1 (since negative numbers are error codes) and  these  are
	// the  values employed  by  the  setpriority() and getpriority() system
	// calls.  The glibc wrapper functions for these system calls handle the
	// translations  between the user-land and kernel representations of the
	// nice value according to the formula unice = 20 - knice. (Thus, the
	// kernel's 40..1 range corresponds to the range -20..19 as seen by user
	// space.)"

	const (
		pidSelf       = 0
		wantNiceLevel = 20 - 9
	)

	// Remember Linux kernel nice levels are upside down.
	if cur, err := syscall.Getpriority(syscall.PRIO_PROCESS, 0); err == nil && cur <= wantNiceLevel {
		// We're done here.
		return nil
	}

	// Move ourselves to a new process group so that we can use the process
	// group variants of Setpriority etc to affect all of our threads in one
	// go. If this fails, bail, so that we don't affect things we shouldn't.
	// If we are already the leader of our own process group, do nothing.
	//
	// Oh and this is because Linux doesn't follow the POSIX threading model
	// where setting the niceness of the process would actually set the
	// niceness of the process, instead it just affects the current thread
	// so we need this workaround...
	if pgid, err := syscall.Getpgid(pidSelf); err != nil {
		// This error really shouldn't happen
		return errors.Wrap(err, "get process group")
	} else if pgid != os.Getpid() {
		// We are not process group leader. Elevate!
		if err := syscall.Setpgid(pidSelf, 0); err != nil {
			return errors.Wrap(err, "set process group")
		}
	}

	if err := syscall.Setpriority(syscall.PRIO_PGRP, pidSelf, wantNiceLevel); err != nil {
		return errors.Wrap(err, "set niceness")
	}

	// Best effort, somewhere to the end of the scale (0 through 7 being the
	// range).
	err := ioprioSet(ioprioClassBE, 5)
	return errors.Wrap(err, "set I/O priority") // wraps nil as nil
}
127034
func (s *GetMaintenanceWindowTaskOutput) SetPriority(v int64) *GetMaintenanceWindowTaskOutput {
	s.Priority = &v
	return s
}
406837
func (s *Finding) SetSeverity(v float64) *Finding {
	s.Severity = &v
	return s
}
1039298
func (s *JobListDescriptor) SetPriority(v int64) *JobListDescriptor {
	s.Priority = &v
	return s
}
150617
func (s *GetMaintenanceWindowExecutionTaskOutput) SetPriority(v int64) *GetMaintenanceWindowExecutionTaskOutput {
	s.Priority = &v
	return s
}
597740
func (s *SamplingRuleUpdate) SetPriority(v int64) *SamplingRuleUpdate {
	s.Priority = &v
	return s
}
627502
func (s *RegisterWorkflowTypeInput) SetDefaultTaskPriority(v string) *RegisterWorkflowTypeInput {
	s.DefaultTaskPriority = &v
	return s
}
407086
func (s *ModifyEventSubscriptionInput) SetSeverity(v string) *ModifyEventSubscriptionInput {
	s.Severity = &v
	return s
}