#include <iostream>
#include <chrono>
#include "ThreadPool.h"
using namespace std;

int main(){
	cout<<"=========================================="<<endl;
	cout<<"     ENTERPRISE FACTORY BOOT SEQUENCE     "<<endl;
	cout<<"=========================================="<<endl;
	{
		ThreadPool factoryPool(4);
		cout<<"[MANAGER] Droping 20 heavy tasks into the queue..."<<endl;
		for(int i=0;i<=20;i++){
			factoryPool.enqueueTask([i](){
				cout<<"   ->Worker grabbed Product "<<i<<". Processing..."<<endl;
				this_thread::sleep_for(chrono::milliseconds(300));
				cout<<"   <-Product "<<i<<" finished and packed!"<<endl;
			});
		}
		cout<<"[MANAGER] All 20 tasks are queued. the Manager is going to lunch."<<endl;
		cout<<"------------------------------------------"<<endl;
	}
	cout<<"============================================"<<endl;
	cout<<"     ALL JOBS COMPLETE. FACTORY CLOSED.     "<<endl;
	cout<<"============================================"<<endl;

	return 0;
}
