mirror of
https://github.com/u2takey/ffmpeg-go.git
synced 2025-10-01 22:32:09 +08:00
fix: add missing method RunWithResource
This commit is contained in:
@@ -26,7 +26,7 @@ func ComplexFilterExample(testInputFile, testOverlayFile, testOutputFile string)
|
||||
// 1386105 root 20 0 2114152 273780 31672 R 50.2 1.7 0:16.79 ffmpeg
|
||||
func TestLimitCpu(t *testing.T) {
|
||||
e := ComplexFilterExample("./sample_data/in1.mp4", "./sample_data/overlay.png", "./sample_data/out2.mp4")
|
||||
err := e.WithCpuCoreRequest(0.1).WithCpuCoreLimit(0.5).RunLinux()
|
||||
err := e.RunWithResource(0.1, 0.5)
|
||||
if err != nil {
|
||||
assert.Nil(t, err)
|
||||
}
|
||||
|
@@ -68,6 +68,10 @@ func writeCGroupFile(rootPath, file string, value string) error {
|
||||
return ioutil.WriteFile(filepath.Join(rootPath, file), []byte(value), 0755)
|
||||
}
|
||||
|
||||
func (s *Stream) RunWithResource(cpuRequest, cpuLimit float32) error {
|
||||
return s.WithCpuCoreRequest(cpuRequest).WithCpuCoreLimit(cpuLimit).RunLinux()
|
||||
}
|
||||
|
||||
func (s *Stream) RunLinux() error {
|
||||
a := s.Context.Value(cgroupConfigKey).(*cgroupConfig)
|
||||
if a.cpuRequest > a.cpuLimit {
|
||||
|
Reference in New Issue
Block a user