SFML 2.5.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

Thread.hpp
1
2//
3// SFML - Simple and Fast Multimedia Library
4// Copyright (C) 2007-2018 Laurent Gomila (laurent@sfml-dev.org)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#ifndef SFML_THREAD_HPP
26#define SFML_THREAD_HPP
27
29// Headers
31#include <SFML/System/Export.hpp>
32#include <SFML/System/NonCopyable.hpp>
33#include <cstdlib>
34
35
36namespace sf
37{
38namespace priv
39{
40 class ThreadImpl;
41 struct ThreadFunc;
42}
43
48 class SFML_SYSTEM_API Thread : NonCopyable
49{
50public:
51
74 template <typename F>
75 Thread(F function);
76
102 template <typename F, typename A>
103 Thread(F function, A argument);
104
125 template <typename C>
126 Thread(void(C::*function)(), C* object);
127
135 ~Thread();
136
146 void launch();
147
159 void wait();
160
172 void terminate();
173
174private:
175
176 friend class priv::ThreadImpl;
177
184 void run();
185
187 // Member data
189 priv::ThreadImpl* m_impl;
190 priv::ThreadFunc* m_entryPoint;
191};
192
193#include <SFML/System/Thread.inl>
194
195} // namespace sf
196
197#endif // SFML_THREAD_HPP
198
199
sf::NonCopyable
Utility class that makes any derived class non-copyable.
Definition: NonCopyable.hpp:42
sf::Thread
Utility class to manipulate threads.
Definition: Thread.hpp:49
sf::Thread::Thread
Thread(F function)
Construct the thread from a functor with no argument.
sf::Thread::Thread
Thread(F function, A argument)
Construct the thread from a functor with an argument.
sf::Thread::wait
void wait()
Wait until the thread finishes.
sf::Thread::launch
void launch()
Run the thread.
sf::Thread::Thread
Thread(void(C::*function)(), C *object)
Construct the thread from a member function and an object.
sf::Thread::terminate
void terminate()
Terminate the thread.
sf::Thread::~Thread
~Thread()
Destructor.