package cn.iocoder.yudao.module.remote.api.robot;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

@EnableScheduling
@Component
@Slf4j
public class RemoteScheduledTasks {

    private static final ExecutorService fixedThreadPool = Executors.newFixedThreadPool(3);

    @Resource
    private RemoteControllerProcessor remoteControllerProcessor;

    // 这个方法将每200毫秒执行一次
    @Scheduled(fixedDelay = 300, timeUnit = TimeUnit.MILLISECONDS)
    public void executeTask() {
        fixedThreadPool.execute(new Runnable() {
            @Override
            public void run() {
                remoteControllerProcessor.processAndSend();
            }
        });
    }



}
