#include <fstream>
#include <monitor>

#include <stdbool.h>

monitor M {};

void notcalled( M & mutex m ) {
	abort();
}

void test( M & mutex m ) {
	int i = 0;
	sout | "Starting" | endl;

	when( false ) waitfor( notcalled, m );

	sout | "Step" | i++ | endl;

	waitfor( notcalled, m ); or else {
		sout | "else called" | endl;
	}

	sout | "Step" | i++ | endl;

	when( true ) waitfor( notcalled, m ); or when( true ) else {
		sout | "else called" | endl;
	}

	sout | "Step" | i++ | endl;

	when( false ) waitfor( notcalled, m ); or when( true ) else {
		sout | "else called" | endl;
	}

	sout | "Step" | i++ | endl;

	when( false ) waitfor( notcalled, m ); or when( false ) else {
		sout | "else called" | endl;
	}

	sout | "Done" | endl;
}

int main() {
	M m;
	test(m);
}