-// ANNA - Anna is Not Nothingness Anymore
-//
-// (c) Copyright 2005-2014 Eduardo Ramos Testillano & Francisco Ruiz Rayo
-//
-// https://bitbucket.org/testillano/anna
-//
-// Redistribution and use in source and binary forms, with or without
-// modification, are permitted provided that the following conditions
-// are met:
-//
-// * Redistributions of source code must retain the above copyright
-// notice, this list of conditions and the following disclaimer.
-// * Redistributions in binary form must reproduce the above
-// copyright notice, this list of conditions and the following disclaimer
-// in the documentation and/or other materials provided with the
-// distribution.
-// * Neither the name of Google Inc. nor the names of its
-// contributors may be used to endorse or promote products derived from
-// this software without specific prior written permission.
-//
-// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-//
-// Authors: eduardo.ramos.testillano@gmail.com
-// cisco.tierra@gmail.com
+// ANNA - Anna is Not Nothingness Anymore //
+// //
+// (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
+// //
+// See project site at http://redmine.teslayout.com/projects/anna-suite //
+// See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
#include <iostream>
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;
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;
int a_id;
int a_value;
- void run () throw (RuntimeException);
+ void run () noexcept(false);
anna_complete_runnable (Waiter);
};
// 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);
// 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;
/* Tx */
void Waiter::initialize ()
- throw (RuntimeException)
+ noexcept(false)
{
if (pipe (a_pipe) == -1) {
string msg (functions::asText ("Waiter::initialize | Id: ", a_id));
/* 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 */
/* Tx */
int Waiter::waitResponse ()
- throw (RuntimeException)
+ noexcept(false)
{
bool receive = io::functions::waitInput (a_pipe [ReadChannel], (Millisecond)500);
/* Ty */
void Waiter::notifyResponse (const int result)
- throw (RuntimeException)
+ noexcept(false)
{
int byte = 0;
a_result = result;
- write (a_pipe [WriteChannel], &byte, sizeof (byte));
+ ssize_t r = write (a_pipe [WriteChannel], &byte, sizeof (byte));
}
// Modela al thread que recibe la respuesta correspondiente a la petición por la
// que debería haber un Waiter esperando.
/* Ty */
void Receiver::run ()
- throw (RuntimeException)
+ noexcept(false)
{
anna::functions::sleep ((Millisecond)(rand () % 1000));
}
Waiter* Context::createWaiter (const int id, const int value)
- throw (RuntimeException)
+ noexcept(false)
{
Guard guard (*this, "Context::createWaiter");
}
void Context::destroyWaiter (Waiter* waiter)
- throw (RuntimeException)
+ noexcept(false)
{
Guard guard (this, "Context::destroyWaiter");