#include "tile/base/internal/background_task_host.h"

#include "gtest/gtest.h"

#include "tile/base/thread/latch.h"

namespace tile {
namespace internal {

TEST(BackgroundTaskHost, All)
{
    // BackgroundTaskHost::Instance()->Start();
    for (int i = 0; i < 1000; ++i) {
        int x = 1;
        Latch latch(1);
        BackgroundTaskHost::Instance()->Queue([&] {
            x = 2;
            latch.CountDown();
        });
        latch.Wait();
        ASSERT_EQ(2, x);
    }
    // BackgroundTaskHost::Instance()->Stop();
    // BackgroundTaskHost::Instance()->Join();
}

}// namespace internal
}// namespace tile
