// ---------------------------------------------------------------------------
// 
//   Lily Engine alpha
// 
//   Copyright (c) 2010 Clifford Jolly
//     http://cliffjolly.com
//     cliff@cliffjolly.com
// 
// ---------------------------------------------------------------------------
// 
//   This program is free software; you can redistribute it and/or modify
//   it under the terms of the GNU General Public License as published by
//   the Free Software Foundation; either version 2 of the License, or
//   (at your option) any later version.
//  
//   This program is distributed in the hope that it will be useful, but
//   WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//   General Public License for more details.
// 
//   You should have received a copy of the GNU General Public License
//   along with this program; if not, write to the Free Software
//   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
//   USA
// -------------------------- END HEADER -------------------------------------

#include "../hacks/winhacks.h"
#include "../thread/thread.h"

#include <boost/bind.hpp>

#include <iostream>

using namespace std;

#include "console.h"

using namespace Console;

bool quit = false;

void runAroundScreaming(int a, int b) {
	
	while(!quit) {
        Threads::ThreadId id = Threads::getMyId();
		out(a) << "Thing foo bar: " << a << " " << b << " id: " << id << endl;
	}
}

int main(int argc, char *argv[]) {
	
    cout << "Starting main " << Threads::getMyId() << endl;

	outSetAttribs("1", "31;1");
	outSetAttribs("3", "32;1");
	
    Threads::Thread t1(boost::bind(&runAroundScreaming, 1, 2));
    Threads::Thread t2(boost::bind(&runAroundScreaming, 3, 4));
	
	int i = 10;
	while(i) {
		usleep(10000);
		out(4) << "Derp derp " << i << endl;
		i--;
	}
	
	quit = true;
	
	t1.join();
	t2.join();
	
	return 0;
}

