ROOTPLOIT
Server: LiteSpeed
System: Linux in-mum-web1878.main-hosting.eu 5.14.0-570.21.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 11 07:22:35 EDT 2025 x86_64
User: u435929562 (435929562)
PHP: 7.4.33
Disabled: system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/go/pkg/mod/github.com/aws/[email protected]/aws/csm/metric_chan.go
package csm

import (
	"sync/atomic"
)

const (
	runningEnum = iota
	pausedEnum
)

var (
	// MetricsChannelSize of metrics to hold in the channel
	MetricsChannelSize = 100
)

type metricChan struct {
	ch     chan metric
	paused *int64
}

func newMetricChan(size int) metricChan {
	return metricChan{
		ch:     make(chan metric, size),
		paused: new(int64),
	}
}

func (ch *metricChan) Pause() {
	atomic.StoreInt64(ch.paused, pausedEnum)
}

func (ch *metricChan) Continue() {
	atomic.StoreInt64(ch.paused, runningEnum)
}

func (ch *metricChan) IsPaused() bool {
	v := atomic.LoadInt64(ch.paused)
	return v == pausedEnum
}

// Push will push metrics to the metric channel if the channel
// is not paused
func (ch *metricChan) Push(m metric) bool {
	if ch.IsPaused() {
		return false
	}

	select {
	case ch.ch <- m:
		return true
	default:
		return false
	}
}