thread.h
Go to the documentation of this file.
1 
11 #pragma once
12 
13 #include <opc/common/interface.h>
15 
16 #include <thread>
17 #include <functional>
18 #include <stdexcept>
19 
20 namespace Common
21 {
22 
24 {
25 public:
27  virtual void OnSuccess() = 0;
29  virtual void OnError(const std::exception & exc) = 0;
30 };
31 
32 typedef std::function<void()> ThreadProc;
33 
34 class Thread
35 {
36 public:
38 
39 public:
41  Thread(std::function<void()> f, ThreadObserver * observer = 0);
42 
43  static Thread::UniquePtr Create(ThreadProc f, ThreadObserver * observer = 0)
44  {
45  return Thread::UniquePtr(new Thread(f, observer));
46  }
47 
48  static Thread::UniquePtr Create(void (*f)(), ThreadObserver * observer = 0)
49  {
50  Common::ThreadProc proc(f);
51  return Thread::UniquePtr(new Common::Thread(proc, observer));
52  }
53 
54  ~Thread();
56  void Join();
57 
58 public:
60  void Run();
62  static void ThreadProc(Thread * thread);
63 
64 private:
67  std::thread Impl;
68 };
69 
70 } // namespace Common
71 
virtual void OnSuccess()=0
thread exited with Success.
Common::ThreadProc Func
Definition: thread.h:66
Addon interface definition GNU LGPL.
f
std::thread Impl
Definition: thread.h:67
static Thread::UniquePtr Create(ThreadProc f, ThreadObserver *observer=0)
Definition: thread.h:43
#define DEFINE_CLASS_POINTERS(ClassName)
Exception declarations GNU LGPL.
std::function< void()> ThreadProc
Definition: thread.h:32
virtual void OnError(const std::exception &exc)=0
Thread exited with error.
ThreadObserver * Observer
Definition: thread.h:65
static Thread::UniquePtr Create(void(*f)(), ThreadObserver *observer=0)
Definition: thread.h:48


ros_opcua_impl_freeopcua
Author(s): Denis Štogl
autogenerated on Tue Jan 19 2021 03:12:08