package standby_ctrl

import (
	"context"
	"game-driver/internal/common"
	"go.uber.org/zap"
)

// Device 设备锁定控制器
func Device(d *common.Device, lock bool, play func(c context.Context) error) func(c context.Context) error {
	return func(c context.Context) error {
		if lock {
			zap.S().Infoln("待机任务锁定设备")
			defer zap.S().Infoln("待机任务解锁设备")

			d.Lock()
			defer d.Unlock()
		}

		return play(c)
	}
}
