Remove dynamic exceptions
[anna.git] / example / core / thread / main.cpp
index 2f454d4..596e9d5 100644 (file)
@@ -30,31 +30,31 @@ private:
    const int a_id;
    const int a_value;
 
-   void run () throw (RuntimeException);
+   void run () noexcept(false);
 
    anna_complete_runnable (Client);
 };
 
 class SOAP {
 public:
-   static int theMethod (const int id, const int value) throw (RuntimeException);
+   static int theMethod (const int id, const int value) noexcept(false);
 };
 
 class Receiver;
 
 class Waiter {
 public:
-   int getId () const throw () { return a_id; }
-   int getValue () const throw () { return a_value; }
+   int getId () const { return a_id; }
+   int getValue () const { return a_value; }
 
-   void setId (const int id) throw () { a_id = id; }
-   void setValue (const int value) throw () { a_value = value; }
+   void setId (const int id) { a_id = id; }
+   void setValue (const int value) { a_value = value; }
 
-   void sendRequest () throw (RuntimeException);
-   int waitResponse () throw (RuntimeException);
-   void notifyResponse (const int result) throw (RuntimeException);   
+   void sendRequest () noexcept(false);
+   int waitResponse () noexcept(false);
+   void notifyResponse (const int result) noexcept(false);   
 
-   void initialize () throw (RuntimeException);
+   void initialize () noexcept(false);
    
 private:
    static const int ReadChannel = 0;
@@ -71,13 +71,13 @@ private:
 
 class Context : public SafeRecycler <Waiter> {
 public:  
-   Waiter* createWaiter (const int id, const int value) throw (RuntimeException);
-   void destroyWaiter (Waiter* waiter) throw (RuntimeException);
-   Waiter* findWaiter (const int id) throw () { return a_waiters.find (id); }
+   Waiter* createWaiter (const int id, const int value) noexcept(false);
+   void destroyWaiter (Waiter* waiter) noexcept(false);
+   Waiter* findWaiter (const int id) { return a_waiters.find (id); }
 
 private:
    struct SortByID {
-      static int value (const Waiter* waiter) throw () { return waiter->getId (); }
+      static int value (const Waiter* waiter) { return waiter->getId (); }
    };
 
    typedef SortedVector <Waiter, SortByID, int> waiter_container;
@@ -93,7 +93,7 @@ private:
    int a_id;
    int a_value;
 
-   void run () throw (RuntimeException);
+   void run () noexcept(false);
 
    anna_complete_runnable (Waiter);
 };
@@ -163,7 +163,7 @@ int main (const int argc, const char** argv)
 // Esto simula el proceso cliente que envía la petición al proceso gSOAP
 /* Se ejecuta desde el thread Tx */
 void Client::run () 
-   throw (RuntimeException)
+   noexcept(false)
 {
    int result = SOAP::theMethod (a_id, a_value);
 
@@ -179,7 +179,7 @@ void Client::run ()
 // que será el que le dé la respuesta "real" en algún momento.
 /* Tx */
 int SOAP::theMethod (const int id, const int value)
-   throw (RuntimeException)
+   noexcept(false)
 {
    int result = -1;
 
@@ -205,7 +205,7 @@ int SOAP::theMethod (const int id, const int value)
 
 /* Tx */
 void Waiter::initialize () 
-   throw (RuntimeException)
+   noexcept(false)
 {
    if (pipe (a_pipe) == -1) {
       string msg (functions::asText ("Waiter::initialize | Id: ", a_id));
@@ -215,7 +215,7 @@ void Waiter::initialize ()
 
 /* Tx */
 void Waiter::sendRequest () 
-   throw (RuntimeException)
+   noexcept(false)
 {
    try {
       /* Ojo que esto generará memory-leaks, pero no es el objeto de éste ejemplo la buena gestión de la memoria */
@@ -231,7 +231,7 @@ void Waiter::sendRequest ()
 
 /* Tx */
 int Waiter::waitResponse () 
-   throw (RuntimeException)
+   noexcept(false)
 {
    bool receive = io::functions::waitInput (a_pipe [ReadChannel], (Millisecond)500);
    
@@ -248,7 +248,7 @@ int Waiter::waitResponse ()
 
 /* Ty */
 void Waiter::notifyResponse (const int result) 
-   throw (RuntimeException)
+   noexcept(false)
 {
    int byte = 0;
    
@@ -261,7 +261,7 @@ void Waiter::notifyResponse (const int result)
 // que debería haber un Waiter esperando.
 /* Ty */
 void Receiver::run () 
-   throw (RuntimeException)
+   noexcept(false)
 {
    anna::functions::sleep ((Millisecond)(rand () % 1000));
 
@@ -282,7 +282,7 @@ void Receiver::run ()
 }
 
 Waiter* Context::createWaiter (const int id, const int value) 
-   throw (RuntimeException)
+   noexcept(false)
 {
    Guard guard (*this, "Context::createWaiter");
    
@@ -302,7 +302,7 @@ Waiter* Context::createWaiter (const int id, const int value)
 }
 
 void Context::destroyWaiter (Waiter* waiter) 
-   throw (RuntimeException)
+   noexcept(false)
 {
    Guard guard (this, "Context::destroyWaiter");