#ifndef THREAD_H_
#define THREAD_H_

#if !defined(TN_PLATFORM_WINDOWS) && !defined(TN_PLATFORM_WINCE)
#define BOOST_THREAD_PLATFORM_PTHREAD
#else
#define BOOST_THREAD_PLATFORM_WIN32
#endif //!defined(TN_PLATFORM_WINDOWS) && !defined(TN_PLATFORM_WINCE)

#if (defined(TN_PLATFORM_WINPHONE) || defined(TN_PLATFORM_WINRT))
#include <thread>
#include <chrono>
namespace Tn
{
	namespace Foundation
	{
		using std::thread;

		typedef std::chrono::system_clock::time_point system_time;
#define system_time_now() std::chrono::system_clock::now()
#define system_time_milliseconds(duration) std::chrono::milliseconds((duration))

        namespace this_thread = std::this_thread;
        namespace chrono = std::chrono;
	}
}
#define SLEEP(duration) std::this_thread::sleep_for(std::chrono::milliseconds((duration)))

#else
#include "boost/thread/thread.hpp"
namespace Tn
{
    namespace Foundation
    {
        using boost::thread;
        namespace Detail
        {
            using namespace boost::detail;
        }
        namespace This_thread
        {
            using namespace boost::this_thread;
        }

		typedef boost::system_time system_time;
#define system_time_now() boost::get_system_time()
#define system_time_milliseconds(duration) boost::posix_time::milliseconds((duration))

        namespace this_thread = boost::this_thread;
        namespace chrono = boost::chrono;
    }
}
#define SLEEP(duration) boost::this_thread::sleep(boost::posix_time::milliseconds((duration)))

#endif

#endif //!__THREAD_H__