#include <stdio.h>
#include <iostream>
#include <crtdbg.h>
#include <boost/asio/thread_pool.hpp>
#include <boost/asio/post.hpp>
using namespace std;
using namespace this_thread;
using namespace chrono;
void threadTest()
{
// 반복문을 돌면서 콘솔에 값을 출력한다.
for (int i = 0; i < 4; i++)
{
cout << i << endl;
sleep_for(microseconds(1));
}
}
int main()
{
boost::asio::thread_pool* pool = new boost::asio::thread_pool(1);
/* 쓰레드 실행 */
post(*pool, threadTest);
post(*pool, threadTest);
post(*pool, threadTest);
pool->join(); // pool 내의 모든 쓰레드가 종료할 때까지 기다린다.
delete pool; // 메모리 해제
_CrtDumpMemoryLeaks(); // 메모리 릭체크 함수.
return 0;
}