4 #ifndef FIRE_GEAR_THREADING_THREAD_HPP_INCLUDED
5 #define FIRE_GEAR_THREADING_THREAD_HPP_INCLUDED
7 #include "fire/export.hpp"
9 #include <boost/smart_ptr/shared_ptr.hpp>
10 #include <boost/thread.hpp>
17 #include "fire/Object.hpp"
18 #include "fire/gear/threading/Runnable.hpp"
51 boost::shared_ptr< fire::gear::threading::Runnable > runnable;
60 explicit Callable(boost::shared_ptr< fire::gear::threading::Runnable > runnable) {
62 this->runnable = runnable;
63 }
catch (
const std::exception& exception) {
73 }
catch (
const std::exception& exception) {
83 this->runnable->run();
84 }
catch (
const std::exception& exception) {
99 boost::shared_ptr< boost::thread > thread;
108 explicit Guard(boost::shared_ptr< boost::thread > thread) {
110 this->thread = thread;
111 }
catch (
const std::exception& exception) {
121 this->thread->join();
122 }
catch (
const std::exception& exception) {
133 boost::shared_ptr< fire::gear::threading::Runnable > runnable;
138 std::auto_ptr< fire::gear::threading::Thread::Callable > callable;
143 boost::shared_ptr< boost::thread > thread;
148 std::auto_ptr< fire::gear::threading::Thread::Guard > guard;
153 std::auto_ptr< boost::this_thread::disable_interruption > interruptionsDisabled;
158 std::auto_ptr< boost::this_thread::restore_interruption > interruptionsEnabled;
165 void disableInterruptions();
170 void enableInterruptions();
178 bool isInterruptable()
const;
183 void setInterruptionPoint();
193 static unsigned getCoresCount();
201 static unsigned getVirtualCoresCount();
209 static std::string getThreadId();
217 static void sleepFor(std::size_t milliseconds);
243 std::string getId()
const;
251 void start(
bool guarded =
false);
269 bool isJoinable()
const;
282 void joinFor(std::size_t milliseconds)
const;
Interfaccia per la gestione di un oggetto che descrive un flusso di esecuzione.
Definition: Runnable.hpp:38
Classe per la gestione di un oggetto.
Definition: Object.hpp:29
Classe per la gestione di un flusso di esecuzione.
Definition: Thread.hpp:39