Fix local server for multiple applications
[anna.git] / source / core / mt / Runnable.cpp
1 // ANNA - Anna is Not Nothingness Anymore                                                         //
2 //                                                                                                //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo                         //
4 //                                                                                                //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite                           //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7
8
9 #include <anna/core/mt/Runnable.hpp>
10 #include <anna/core/tracing/Logger.hpp>
11
12 using namespace std;
13 using namespace anna;
14
15 void Runnable::requestStop()
16 noexcept(false) {
17   if(a_isRunning == true)
18     a_requestedStop = true;
19 }
20
21 void Runnable::run()
22 noexcept(false) {
23   a_requestedStop = false;
24
25   while(hasRequestedStop() == false) {
26     try {
27       do_action();
28     } catch(RuntimeException& ex) {
29       ex.trace();
30     }
31   }
32 }
33