#include <atomic>

struct thread {};

struct cluster {
	void add();
	void remove();
	thread * next();
};

struct processor {

	cluster cluster;
	std::atomic<bool> stop;
	volatile bool idle;
};


void run(thread * ) {
	// verify preemption

	// run Thread

	// verify preemption

	// finish Running
}

void main(processor & self) {

	self.cluster.add();

	while(!self.stop) {
		if(thread * t = self.cluster.next()) {
			run(t);
			continue;
		}

		self.set_idle();
		std::atomic_thread_fence();

		if(thread * t = self.cluster.next()) {
			self.idle = false;
			run(t);
			continue;
		}

		halt();
	}

	self.cluster.remove();

}