mirror of
https://github.com/criyle/go-judge.git
synced 2025-11-04 14:50:02 +08:00
36 lines
758 B
Go
36 lines
758 B
Go
package linuxcontainer
|
|
|
|
import "time"
|
|
|
|
var _ CgroupPool = &FakeCgroupPool{}
|
|
|
|
// FakeCgroupPool implements cgroup pool but not actually do pool
|
|
type FakeCgroupPool struct {
|
|
builder CgroupBuilder
|
|
cfsPeriod time.Duration
|
|
}
|
|
|
|
// NewFakeCgroupPool creates FakeCgroupPool
|
|
func NewFakeCgroupPool(builder CgroupBuilder, cfsPeriod time.Duration) CgroupPool {
|
|
return &FakeCgroupPool{builder: builder, cfsPeriod: cfsPeriod}
|
|
}
|
|
|
|
// Get gets new cgroup
|
|
func (f *FakeCgroupPool) Get() (Cgroup, error) {
|
|
cg, err := f.builder.Build()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &wCgroup{cg: cg, cfsPeriod: f.cfsPeriod}, nil
|
|
}
|
|
|
|
// Put destroy the cgroup
|
|
func (f *FakeCgroupPool) Put(c Cgroup) {
|
|
c.Destroy()
|
|
}
|
|
|
|
// Shutdown noop
|
|
func (f *FakeCgroupPool) Shutdown() {
|
|
|
|
}
|