libfilezilla
thread.hpp
Go to the documentation of this file.
1 #ifndef LIBFILEZILLA_THREAD_HEADER
2 #define LIBFILEZILLA_THREAD_HEADER
3 
4 #include "libfilezilla.hpp"
5 
6 #include <functional>
7 
8 #if !defined(FZ_WINDOWS) || !(defined(__MINGW32__) || defined(__MINGW64__))
9 #include <thread>
10 #endif
11 
16 namespace fz {
17 
29 class FZ_PUBLIC_SYMBOL thread final
30 {
31 public:
32 #if defined(FZ_WINDOWS) && (defined(__MINGW32__) || defined(__MINGW64__))
33  typedef uint32_t id;
34 #else
35  typedef std::thread::id id;
36 #endif
37 
38  thread() = default;
39 
43 
48  bool run(std::function<void()> && f);
49 
60  void join();
61 
66  bool joinable() const;
67 
69  static id own_id();
70 
71 private:
72  class impl;
73  friend class impl;
74  impl* impl_{};
75 };
76 }
77 
78 #endif
Spawns and represents a new thread of execution.
Definition: thread.hpp:30
bool run(std::function< void()> &&f)
Start the thread.
~thread()
Implicitly calls join()
void join()
Join the thread.
bool joinable() const
A thread is joinable after having been started and before it has been joined.
static id own_id()
Returns unique id of the thread calling the function.
Sets some global macros and further includes string.hpp.
The namespace used by libfilezilla.
Definition: apply.hpp:17