// Copyright (C) 2014 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_THREAD_HPP #define NAZARA_THREAD_HPP #include #include #include #include class NzThreadImpl; class NAZARA_API NzThread : NzNonCopyable { public: class Id; NzThread(); template NzThread(F function); template NzThread(F function, Args... args); template NzThread(void (C::*function)(), C* object); NzThread(NzThread&& other); ~NzThread(); void Detach(); Id GetId() const; bool IsJoinable() const; void Join(); NzThread& operator=(NzThread&& thread); static unsigned int HardwareConcurrency(); static void Sleep(nzUInt32 milliseconds); private: void CreateImpl(NzFunctor* functor); NzThreadImpl* m_impl; }; class NAZARA_API NzThread::Id { friend NzThread; public: NAZARA_API friend bool operator==(const Id& lhs, const Id& rhs); NAZARA_API friend bool operator!=(const Id& lhs, const Id& rhs); NAZARA_API friend bool operator<(const Id& lhs, const Id& rhs); NAZARA_API friend bool operator<=(const Id& lhs, const Id& rhs); NAZARA_API friend bool operator>(const Id& lhs, const Id& rhs); NAZARA_API friend bool operator>=(const Id& lhs, const Id& rhs); NAZARA_API friend std::ostream& operator<<(std::ostream& o, const Id& id); private: Id(NzThreadImpl* thread); NzThreadImpl* m_id = nullptr; }; #include #endif // NAZARA_THREAD_HPP