// Copyright (C) 2012 Jérôme Leclercq // This file is part of the "Nazara Engine". // For conditions of distribution and use, see copyright notice in Config.hpp // Inspiré du code de la SFML par Laurent Gomila #pragma once #ifndef NAZARA_THREAD_HPP #define NAZARA_THREAD_HPP #include #include #include class NzThreadImpl; class NAZARA_API NzThread : NzNonCopyable { friend class NzThreadImpl; public: class NAZARA_API Id { friend class NzThread; friend class NzThreadImpl; public: Id() : m_handle(nullptr) {} Id(Id&& rhs) = default; ~Id(); Id& operator=(Id&& rhs) = default; bool operator==(const Id& rhs) const; bool operator!=(const Id& rhs) const; private: Id(void* handle) : m_handle(handle) {} Id(const NzThreadImpl* thread); void* m_handle; }; template NzThread(F function); template NzThread(F function, Args... args); ~NzThread(); Id GetId() const; bool IsCurrent() const; void Launch(bool independent = false); void Join(); void Terminate(); static Id GetCurrentId(); static void Sleep(nzUInt32 time); private: NzFunctor* m_func; NzThreadImpl* m_impl; bool m_independent; }; #include #endif // NAZARA_THREAD_HPP