/*  Copyright (C) 2015  Povilas Kanapickas <povilas@radix.lt>

    This file is part of cppreference-doc

    This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
    Unported License. To view a copy of this license, visit
    http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
    Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.

    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 1.3 or
    any later version published by the Free Software Foundation; with no
    Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
*/

#ifndef CPPREFERENCE_THREAD_H
#define CPPREFERENCE_THREAD_H

#if CPPREFERENCE_STDVER>= 2011

namespace std {

class thread {
public:
    class id {
    public:
        id();
    };

    typedef void* native_handle_type; // actually impl-defined

    thread();
    thread(const thread&) = delete;
    thread(thread&& other);
    template <class Function, class ...Args>
    explicit thread(Function&& f, Args&& ... args);
    ~thread();

    thread& operator=(const thread&) = delete;
    thread& operator=(thread&& t);

    bool joinable() const;
    id get_id() const;
    native_handle_type native_handle();
    static unsigned hardware_concurrency();

    void join();
    void detach();
    void swap(thread& t);
};

bool operator==(thread::id lhs, thread::id rhs);
bool operator!=(thread::id lhs, thread::id rhs);
bool operator<(thread::id lhs, thread::id rhs);
bool operator<=(thread::id lhs, thread::id rhs);
bool operator>(thread::id lhs, thread::id rhs);
bool operator>=(thread::id lhs, thread::id rhs);

template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& out, thread::id id);

void swap(thread& lhs, thread& rhs);

namespace this_thread {
void yield();
std::thread::id get_id();
template<class Rep, class Period>
void sleep_for(const std::chrono::duration<Rep, Period>& sleep_duration);
template<class Clock, class Duration>
void sleep_until(const std::chrono::time_point<Clock, Duration>& sleep_time);

} // namespace this_thread

} // namespace std

#endif // CPPREFERENCE_STDVER>= 2011

#endif // CPPREFERENCE_THREAD_H
