package com.tashow.cloud.canal.service;

import java.util.List;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;

public class SqlTaskQueue {
    private static final Queue<SqlTask> queue = new ConcurrentLinkedQueue<>();

    public static void add(SqlTask task) {
        queue.add(task);
    }

    public static boolean isEmpty() {
        return queue.isEmpty();
    }

    public static SqlTask poll() {
        return queue.poll();
    }

    public static int size() {
        return queue.size();
    }

    public static List<SqlTask> drainAll() {
        List<SqlTask> list = new java.util.ArrayList<>();
        queue.forEach(list::add);
        queue.clear();
        return list;
    }
}
