mirror of
https://github.com/criyle/go-judge.git
synced 2025-11-04 14:50:02 +08:00
39 lines
794 B
Go
39 lines
794 B
Go
package envexec
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/criyle/go-sandbox/container"
|
|
"github.com/criyle/go-sandbox/runner"
|
|
)
|
|
|
|
// EnvironmentPool implements pool of environments
|
|
type EnvironmentPool interface {
|
|
Get() (container.Environment, error)
|
|
Put(container.Environment)
|
|
}
|
|
|
|
// Cgroup defines interface to limit and monitor resources consumption of a process
|
|
type Cgroup interface {
|
|
SetMemoryLimit(runner.Size) error
|
|
SetProcLimit(uint64) error
|
|
|
|
CPUUsage() (time.Duration, error)
|
|
MemoryUsage() (runner.Size, error)
|
|
|
|
AddProc(int) error
|
|
Reset() error
|
|
Destory() error
|
|
}
|
|
|
|
// CPUUsager access process cpu usage (from cgroup)
|
|
type CPUUsager interface {
|
|
CPUUsage() (time.Duration, error)
|
|
}
|
|
|
|
// CgroupPool implements pool of Cgroup
|
|
type CgroupPool interface {
|
|
Get() (Cgroup, error)
|
|
Put(Cgroup)
|
|
}
|