Commit 4151aac8 authored by Dominik Charousset's avatar Dominik Charousset

maintenance

Firstly, this patch resolved some minor issues:

- fixed some minor mistakes in the documentation
- fixed several warnings such as sign conversions, weak vtables, etc.
- got rid of unused enum value `hm_timeout_msg`
- use 64bit integer for duration type, closes #9
- throw exception when trying to use a negative timeout for receiving messages

Secondly, this patch enforces a better and more C++11-ish coding style:

- use `noexcept` instead of `throw()`
- annotate fallthroughs in switch statements via `CPPA_ANNOTATE_FALLTHROUGH`
- prefer `enum class` over `enum`
- prefer exhaustive list of cases over relying on a `default:` case
- suppress third party warnings via `CPPA_PUSH_WARNINGS`/`CPPA_POP_WARNINGS`
- use `[[noreturn]]` whenever possible
parent ec7de3cf
......@@ -138,6 +138,7 @@ set(LIBCPPA_SRC
src/abstract_channel.cpp
src/abstract_group.cpp
src/abstract_tuple.cpp
src/acceptor.cpp
src/actor.cpp
src/actor_addr.cpp
src/actor_companion.cpp
......@@ -180,6 +181,7 @@ set(LIBCPPA_SRC
src/get_mac_addresses.cpp
src/group.cpp
src/group_manager.cpp
src/input_stream.cpp
src/ipv4_acceptor.cpp
src/ipv4_io_stream.cpp
src/local_actor.cpp
......@@ -195,6 +197,7 @@ set(LIBCPPA_SRC
src/object.cpp
src/object_array.cpp
src/opt.cpp
src/output_stream.cpp
src/partial_function.cpp
src/primitive_variant.cpp
src/ref_counted.cpp
......@@ -207,6 +210,7 @@ set(LIBCPPA_SRC
src/serializer.cpp
src/shared_spinlock.cpp
src/singleton_manager.cpp
src/stream.cpp
src/string_serialization.cpp
src/sync_request_bouncer.cpp
src/to_uniform_name.cpp
......
......@@ -244,6 +244,7 @@ src/abstract_actor.cpp
src/abstract_channel.cpp
src/abstract_group.cpp
src/abstract_tuple.cpp
src/acceptor.cpp
src/actor.cpp
src/actor_addr.cpp
src/actor_companion.cpp
......@@ -285,6 +286,7 @@ src/get_mac_addresses.cpp
src/get_root_uuid.cpp
src/group.cpp
src/group_manager.cpp
src/input_stream.cpp
src/ipv4_acceptor.cpp
src/ipv4_io_stream.cpp
src/local_actor.cpp
......@@ -306,6 +308,7 @@ src/opencl/global.cpp
src/opencl/opencl_metainfo.cpp
src/opencl/program.cpp
src/opt.cpp
src/output_stream.cpp
src/partial_function.cpp
src/peer.cpp
src/peer_acceptor.cpp
......@@ -321,6 +324,7 @@ src/scoped_actor.cpp
src/serializer.cpp
src/shared_spinlock.cpp
src/singleton_manager.cpp
src/stream.cpp
src/string_serialization.cpp
src/sync_request_bouncer.cpp
src/to_uniform_name.cpp
......
......@@ -114,13 +114,15 @@ class abstract_actor : public abstract_channel {
/**
* @brief Links this actor to @p whom.
* @param other Actor instance that whose execution is coupled to the
* execution of this Actor.
* @param whom Actor instance that whose execution is coupled to the
* execution of this Actor.
*/
virtual void link_to(const actor_addr& whom);
/**
* @copydoc abstract_actor::link_to(const actor_addr&)
* @brief Links this actor to @p whom.
* @param whom Actor instance that whose execution is coupled to the
* execution of this Actor.
*/
template<typename ActorHandle>
void link_to(const ActorHandle& whom) {
......@@ -129,13 +131,15 @@ class abstract_actor : public abstract_channel {
/**
* @brief Unlinks this actor from @p whom.
* @param other Linked Actor.
* @param whom Linked Actor.
* @note Links are automatically removed if the actor finishes execution.
*/
virtual void unlink_from(const actor_addr& whom);
/**
* @copydoc abstract_actor::unlink_from(const actor_addr&)
* @brief Unlinks this actor from @p whom.
* @param whom Linked Actor.
* @note Links are automatically removed if the actor finishes execution.
*/
template<class ActorHandle>
void unlink_from(const ActorHandle& whom) {
......
......@@ -62,6 +62,8 @@ class abstract_group : public abstract_channel {
public:
~abstract_group();
class subscription;
// needs access to unsubscribe()
......@@ -105,6 +107,8 @@ class abstract_group : public abstract_channel {
public:
virtual ~module();
/**
* @brief Get the name of this module implementation.
* @returns The name of this module implementation.
......
......@@ -52,6 +52,8 @@ class actor_proxy : public extend<abstract_actor>::with<enable_weak_ptr> {
public:
~actor_proxy();
/**
* @brief Establishes a local link state that's not synchronized back
* to the remote instance.
......
......@@ -160,8 +160,7 @@ compound_member(const std::pair<GRes (Parent::*)() const,
* @brief Adds a new type mapping for @p C to the libcppa type system.
* @tparam C A class that is either empty or is default constructible,
* copy constructible, and comparable.
* @param arg First members of @p C.
* @param args Additional members of @p C.
* @param args Members of @p C.
* @warning @p announce is <b>not</b> thead safe!
*/
template<class C, typename... Ts>
......
......@@ -95,7 +95,11 @@ class behavior {
inline const util::duration& timeout() const;
/**
* @copydoc partial_function::operator()()
* @brief Returns a value if @p arg was matched by one of the
* handler of this behavior, returns @p nothing otherwise.
* @note This member function can return @p nothing even if
* {@link defined_at()} returns @p true, because {@link defined_at()}
* does not evaluate guards.
*/
template<typename T>
inline optional<any_tuple> operator()(T&& arg);
......
......@@ -186,7 +186,7 @@ class blocking_actor
* )
* .until([&]() { return (++i >= 10); };
* @endcode
* @param bhvr Denotes the actor's response the next incoming message.
* @param args Denotes the actor's response the next incoming message.
* @returns A functor providing the @c until member function.
*/
template<typename... Ts>
......
......@@ -42,17 +42,40 @@
#define CPPA_MINOR_VERSION ((CPPA_VERSION / 100) % 1000)
#define CPPA_PATCH_VERSION (CPPA_VERSION % 100)
// detect compiler and set CPPA_DEPRECATED
// sets CPPA_DEPRECATED, CPPA_ANNOTATE_FALLTHROUGH,
// CPPA_PUSH_WARNINGS and CPPA_POP_WARNINGS
#if defined(__clang__)
# define CPPA_CLANG
# define CPPA_DEPRECATED __attribute__((__deprecated__))
# define CPPA_PUSH_WARNINGS \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Wall\"") \
_Pragma("clang diagnostic ignored \"-Werror\"") \
_Pragma("clang diagnostic ignored \"-Wdeprecated\"") \
_Pragma("clang diagnostic ignored \"-Wdisabled-macro-expansion\"") \
_Pragma("clang diagnostic ignored \"-Wextra-semi\"") \
_Pragma("clang diagnostic ignored \"-Wdocumentation\"") \
_Pragma("clang diagnostic ignored \"-Wweak-vtables\"") \
_Pragma("clang diagnostic ignored \"-Wundef\"")
# define CPPA_POP_WARNINGS \
_Pragma("clang diagnostic pop")
# define CPPA_ANNOTATE_FALLTHROUGH [[clang::fallthrough]]
#elif defined(__GNUC__)
# define CPPA_GCC
# define CPPA_DEPRECATED __attribute__((__deprecated__))
# define CPPA_PUSH_WARNINGS
# define CPPA_POP_WARNINGS
# define CPPA_ANNOTATE_FALLTHROUGH static_cast<void>(0)
#elif defined(_MSC_VER)
# define CPPA_DEPRECATED __declspec(deprecated)
# define CPPA_PUSH_WARNINGS
# define CPPA_POP_WARNINGS
# define CPPA_ANNOTATE_FALLTHROUGH static_cast<void>(0)
#else
# define CPPA_DEPRECATED
# define CPPA_PUSH_WARNINGS
# define CPPA_POP_WARNINGS
# define CPPA_ANNOTATE_FALLTHROUGH static_cast<void>(0)
#endif
// detect OS
......
......@@ -68,8 +68,7 @@ class deserializer {
//virtual std::string seek_object() = 0;
/**
* @brief Begins deserialization of an object of type @p type_name.
* @param type_name The platform-independent @p libcppa type name.
* @brief Begins deserialization of a new object.
*/
virtual const uniform_type_info* begin_object() = 0;
......
......@@ -54,6 +54,8 @@ class actor_registry : public singleton_mixin<actor_registry> {
public:
~actor_registry();
/**
* @brief A registry entry consists of a pointer to the actor and an
* exit reason. An entry with a nullptr means the actor has finished
......
......@@ -36,7 +36,7 @@ namespace cppa { namespace detail {
namespace {
// encodes ASCII characters to 6bit encoding
constexpr char encoding_table[] = {
constexpr unsigned char encoding_table[] = {
/* ..0 ..1 ..2 ..3 ..4 ..5 ..6 ..7 ..8 ..9 ..A ..B ..C ..D ..E ..F */
/* 0.. */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
/* 1.. */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
......
......@@ -42,7 +42,7 @@ namespace cppa { namespace detail { namespace fd_util {
std::string last_socket_error_as_string();
// throws ios_base::failure and adds errno failure if @p add_errno_failure
void throw_io_failure(const char* what, bool add_errno_failure = true);
void throw_io_failure [[noreturn]] (const char* what, bool add_errno = true);
// sets fd to nonblocking if <tt>set_nonblocking == true</tt>
// or to blocking if <tt>set_nonblocking == false</tt>
......
......@@ -48,6 +48,8 @@ class group_manager : public singleton_mixin<group_manager> {
public:
~group_manager();
group get(const std::string& module_name,
const std::string& group_identifier);
......
......@@ -46,6 +46,8 @@ class handle : util::comparable<Subtype> {
m_id = other.id();
}
handle(const handle& other) : m_id(other.m_id) { }
Subtype& operator=(const handle& other) {
m_id = other.id();
return *static_cast<Subtype*>(this);
......
......@@ -35,6 +35,8 @@
#ifndef IEEE_754_HPP
#define IEEE_754_HPP
#include <cmath>
namespace cppa { namespace detail {
template<typename T>
......@@ -42,12 +44,13 @@ struct ieee_754_trait;
template<>
struct ieee_754_trait<float> {
static constexpr std::uint32_t bits = 32;
static constexpr std::uint32_t expbits = 8;
static constexpr float zero = 0.0f;
using packed_type = std::uint32_t;
using signed_packed_type = std::int32_t;
using float_type = float;
static constexpr std::uint32_t bits = 32; // number of bits
static constexpr std::uint32_t expbits = 8; // bits used for exponent
static constexpr float zero = 0.0f; // the value 0
static constexpr float p5 = 0.5f; // the value 0.5
using packed_type = std::uint32_t; // unsigned integer type
using signed_packed_type = std::int32_t; // signed integer type
using float_type = float; // floating point type
};
template<>
......@@ -58,6 +61,7 @@ struct ieee_754_trait<double> {
static constexpr std::uint64_t bits = 64;
static constexpr std::uint64_t expbits = 11;
static constexpr double zero = 0.0;
static constexpr double p5 = 0.5;
using packed_type = std::uint64_t;
using signed_packed_type = std::int64_t;
using float_type = double;
......@@ -71,7 +75,7 @@ typename ieee_754_trait<T>::packed_type pack754(T f) {
typedef ieee_754_trait<T> trait;
typedef typename trait::packed_type result_type;
// filter special type
if (f == trait::zero) return 0;
if (fabs(f) <= trait::zero) return 0; // only true if f equals +0 or -0
auto significandbits = trait::bits - trait::expbits - 1; // -1 for sign bit
// check sign and begin normalization
result_type sign;
......@@ -95,8 +99,10 @@ typename ieee_754_trait<T>::packed_type pack754(T f) {
--shift;
}
fnorm = fnorm - static_cast<T>(1);
// calculate 2^significandbits
auto pownum = static_cast<result_type>(1) << significandbits;
// calculate the binary form (non-float) of the significand data
result_type significand = fnorm * ((static_cast<result_type>(1) << significandbits) + 0.5f);
auto significand = static_cast<result_type>(fnorm * (pownum + trait::p5));
// get the biased exponent
auto exp = shift + ((1 << (trait::expbits - 1)) - 1); // shift + bias
// return the final answer
......@@ -107,6 +113,7 @@ typename ieee_754_trait<T>::packed_type pack754(T f) {
template<typename T>
typename ieee_754_trait<T>::float_type unpack754(T i) {
typedef ieee_754_trait<T> trait;
typedef typename trait::signed_packed_type signed_type;
typedef typename trait::float_type result_type;
if (i == 0) return trait::zero;
auto significandbits = trait::bits - trait::expbits - 1; // -1 for sign bit
......@@ -115,8 +122,10 @@ typename ieee_754_trait<T>::float_type unpack754(T i) {
result /= (static_cast<T>(1) << significandbits); // convert back to float
result += static_cast<result_type>(1); // add the one back on
// deal with the exponent
auto si = static_cast<signed_type>(i);
auto bias = (1 << (trait::expbits - 1)) - 1;
typename trait::signed_packed_type shift = ((i >> significandbits) & ((static_cast<typename trait::signed_packed_type>(1) << trait::expbits) - 1)) - bias;
auto pownum = static_cast<signed_type>(1) << trait::expbits;
auto shift = static_cast<signed_type>(((si >> significandbits) & (pownum - 1)) - bias);
while (shift > 0) {
result *= static_cast<result_type>(2);
--shift;
......
......@@ -62,6 +62,8 @@ class event_based_actor : public extend<local_actor, event_based_actor>::
event_based_actor();
~event_based_actor();
protected:
/**
......
......@@ -45,13 +45,17 @@ class cppa_exception : public std::exception {
public:
~cppa_exception() throw();
~cppa_exception();
cppa_exception() = delete;
cppa_exception(const cppa_exception&) = default;
cppa_exception& operator=(const cppa_exception&) = default;
/**
* @brief Returns the error message.
* @returns The error message as C-string.
*/
const char* what() const throw();
const char* what() const noexcept;
protected:
......@@ -80,14 +84,19 @@ class actor_exited : public cppa_exception {
public:
~actor_exited();
actor_exited(std::uint32_t exit_reason);
actor_exited(const actor_exited&) = default;
actor_exited& operator=(const actor_exited&) = default;
/**
* @brief Gets the exit reason.
* @returns The exit reason of the terminating actor either set via
* {@link quit} or by a special (exit) message.
*/
inline std::uint32_t reason() const throw();
inline std::uint32_t reason() const noexcept;
private:
......@@ -103,8 +112,11 @@ class network_error : public cppa_exception {
public:
~network_error();
network_error(std::string&& what_str);
network_error(const std::string& what_str);
network_error(const network_error&) = default;
network_error& operator=(const network_error&) = default;
};
......@@ -116,13 +128,17 @@ class bind_failure : public network_error {
public:
~bind_failure();
bind_failure(int bind_errno);
bind_failure(const bind_failure&) = default;
bind_failure& operator=(const bind_failure&) = default;
/**
* @brief Gets the socket API error code.
* @returns The errno set by <tt>bind()</tt>.
*/
inline int error_code() const throw();
inline int error_code() const noexcept;
private:
......@@ -130,11 +146,11 @@ class bind_failure : public network_error {
};
inline std::uint32_t actor_exited::reason() const throw() {
inline std::uint32_t actor_exited::reason() const noexcept {
return m_reason;
}
inline int bind_failure::error_code() const throw() {
inline int bind_failure::error_code() const noexcept {
return m_errno;
}
......
......@@ -74,8 +74,12 @@ class blocking_single_reader_queue {
m_cv.notify_one();
return true;
}
default: return true;
case queue_closed: return false;
case enqueued:
// enqueued message to a running actor's mailbox
return true;
case queue_closed:
// actor no longer alive
return false;
}
}
......
......@@ -53,7 +53,7 @@ class acceptor {
public:
virtual ~acceptor() { }
virtual ~acceptor();
/**
* @brief Returns the internal file descriptor. This descriptor is needed
......
......@@ -62,13 +62,13 @@ class buffered_writing : public Base {
catch (std::exception& e) {
CPPA_LOG_ERROR(to_verbose_string(e));
static_cast<void>(e); // keep compiler happy
return write_failure;
return continue_writing_result::failure;
}
if (written != m_buf.size()) {
CPPA_LOG_DEBUG("tried to write " << m_buf.size() << "bytes, "
<< "only " << written << " bytes written");
m_buf.erase_leading(written);
return write_continue_later;
return continue_writing_result::continue_later;
}
else {
m_buf.clear();
......@@ -76,7 +76,7 @@ class buffered_writing : public Base {
CPPA_LOG_DEBUG("write done, " << written << " bytes written");
}
}
return write_done;
return continue_writing_result::done;
}
inline bool has_unwritten_data() const {
......@@ -118,7 +118,7 @@ class buffered_writing : public Base {
inline middleman* parent() {
return m_parent;
}
typedef buffered_writing combined_type;
private:
......
......@@ -43,21 +43,21 @@ namespace cppa { namespace io {
* @brief Denotes the return value of
* {@link continuable::continue_reading()}.
*/
enum continue_reading_result {
read_failure,
read_closed,
read_continue_later
enum class continue_reading_result {
failure,
closed,
continue_later
};
/**
* @brief Denotes the return value of
* {@link continuable::continue_writing()}.
*/
enum continue_writing_result {
write_failure,
write_closed,
write_continue_later,
write_done
enum class continue_writing_result {
failure,
closed,
continue_later,
done
};
/**
......
......@@ -44,6 +44,8 @@ class input_stream : public virtual ref_counted {
public:
~input_stream();
/**
* @brief Returns the internal file descriptor. This descriptor is needed
* for socket multiplexing using select().
......
......@@ -44,6 +44,8 @@ class output_stream : public virtual ref_counted {
public:
~output_stream();
/**
* @brief Returns the internal file descriptor. This descriptor is needed
* for socket multiplexing using select().
......
......@@ -57,6 +57,8 @@ class sync_request_info : public extend<memory_managed>::with<memory_cached> {
typedef sync_request_info* pointer;
~sync_request_info();
pointer next; // intrusive next pointer
actor_addr sender; // points to the sender of the message
message_id mid; // sync message ID
......
......@@ -39,7 +39,13 @@ namespace cppa { namespace io {
/**
* @brief A stream capable of both reading and writing.
*/
class stream : public input_stream, public output_stream { };
class stream : public input_stream, public output_stream {
public:
~stream();
};
/**
* @brief An IO stream pointer.
......
......@@ -252,18 +252,17 @@ class local_actor : public extend<abstract_actor>::with<memory_cached> {
void send_exit(const actor_addr& whom, std::uint32_t reason);
/**
* @copydoc send_exit(const actor_addr&, std::uint32_t)
* @brief Sends an exit message to @p whom.
*/
inline void send_exit(const actor& whom, std::uint32_t reason) {
send_exit(whom.address(), reason);
}
/**
* @copydoc send_exit(const actor_addr&, std::uint32_t)
* @brief Sends an exit message to @p whom.
*/
template<typename... Rs>
void send_exit(const typed_actor<Rs...>& whom,
std::uint32_t reason) {
void send_exit(const typed_actor<Rs...>& whom, std::uint32_t reason) {
send_exit(whom.address(), reason);
}
......@@ -300,7 +299,7 @@ class local_actor : public extend<abstract_actor>::with<memory_cached> {
* @param whom Receiver of the message.
* @param rtime Relative time to delay the message in
* microseconds, milliseconds, seconds or minutes.
* @param data Message content as a tuple.
* @param args Message content as a tuple.
*/
template<typename... Ts>
void delayed_send(message_priority prio, const channel& whom,
......@@ -314,7 +313,7 @@ class local_actor : public extend<abstract_actor>::with<memory_cached> {
* @param whom Receiver of the message.
* @param rtime Relative time to delay the message in
* microseconds, milliseconds, seconds or minutes.
* @param data Message content as a tuple.
* @param args Message content as a tuple.
*/
template<typename... Ts>
void delayed_send(const channel& whom, const util::duration& rtime,
......@@ -363,7 +362,7 @@ class local_actor : public extend<abstract_actor>::with<memory_cached> {
* {@link on_exit()}.
* @note Throws {@link actor_exited} to unwind the stack
* when called in context-switching or thread-based actors.
* @warning This member function throws imeediately in thread-based actors
* @warning This member function throws immediately in thread-based actors
* that do not use the behavior stack, i.e., actors that use
* blocking API calls such as {@link receive()}.
*/
......@@ -394,15 +393,15 @@ class local_actor : public extend<abstract_actor>::with<memory_cached> {
/**
* @brief Adds a unidirectional @p monitor to @p whom.
*
* @whom sends a "DOWN" message to this actor as part of its termination.
* @param whom The actor that should be monitored by this actor.
* @note Each call to @p monitor creates a new, independent monitor.
*/
void monitor(const actor_addr& whom);
/**
* @copydoc monitor(const actor_addr&)
* @brief Adds a unidirectional @p monitor to @p whom.
* @param whom The actor that should be monitored by this actor.
* @note Each call to @p monitor creates a new, independent monitor.
*/
inline void monitor(const actor& whom) {
monitor(whom.address());
......@@ -414,6 +413,10 @@ class local_actor : public extend<abstract_actor>::with<memory_cached> {
*/
void demonitor(const actor_addr& whom);
/**
* @brief Removes a monitor from @p whom.
* @param whom A monitored actor.
*/
inline void demonitor(const actor& whom) {
demonitor(whom.address());
}
......
......@@ -167,8 +167,8 @@ oss_wr operator<<(oss_wr&& lhs, T rhs) {
std::cerr << "[" << lvlname << "] " << classname << "::" \
<< funname << ": " << message << "\nStack trace:\n"; \
void* bt_array[20]; \
size_t size = ::cppa::detail::backtrace(bt_array, 20); \
::cppa::detail::backtrace_symbols_fd(bt_array, size, 2); \
auto cppa_bt_size = ::cppa::detail::backtrace(bt_array, 20); \
::cppa::detail::backtrace_symbols_fd(bt_array, cppa_bt_size, 2); \
} CPPA_VOID_STMT
#ifndef CPPA_LOG_LEVEL
......
......@@ -59,6 +59,8 @@ class mailbox_element : public extend<memory_managed>::with<memory_cached> {
any_tuple msg; // 'content field'
message_id mid;
~mailbox_element();
mailbox_element(mailbox_element&&) = delete;
mailbox_element(const mailbox_element&) = delete;
mailbox_element& operator=(mailbox_element&&) = delete;
......
......@@ -307,7 +307,7 @@ namespace cppa {
/**
* @brief Starts a match expression.
* @param what Tuple or value that should be matched against a pattern.
* @param what Tuple that should be matched against a pattern.
* @returns A helper object providing <tt>operator(...)</tt>.
*/
inline detail::match_helper match(any_tuple what) {
......@@ -315,7 +315,9 @@ inline detail::match_helper match(any_tuple what) {
}
/**
* @copydoc match(any_tuple)
* @brief Starts a match expression.
* @param what Value that should be matched against a pattern.
* @returns A helper object providing <tt>operator(...)</tt>.
*/
template<typename T>
detail::match_helper match(T&& what) {
......
......@@ -41,7 +41,7 @@ namespace cppa {
struct invalid_message_id { constexpr invalid_message_id() { } };
/**
* @brief
* @brief Denotes whether a message is asynchronous or synchronous
* @note Asynchronous messages always have an invalid message id.
*/
class message_id : util::comparable<message_id> {
......
......@@ -52,6 +52,8 @@ class node_id : public ref_counted, util::comparable<node_id> {
public:
~node_id();
/**
* @brief @c libcppa uses 160 bit hashes (20 bytes).
*/
......@@ -77,7 +79,7 @@ class node_id : public ref_counted, util::comparable<node_id> {
/**
* @brief Creates @c this from @p process_id and @p hash.
* @param process_id System-wide unique process identifier.
* @param hash Unique node id.
* @param node_id Unique node id.
*/
node_id(std::uint32_t process_id, const host_id_type& node_id);
......
......@@ -114,7 +114,8 @@ class optional {
inline bool empty() const { return !m_valid; }
/**
* @copydoc valid()
* @brief Returns @p true if this @p option has a valid value;
* otherwise @p false.
*/
inline explicit operator bool() const { return valid(); }
......
......@@ -89,11 +89,11 @@ class partial_function {
inline bool defined_at(const any_tuple& value);
/**
* @brief Returns @p true if this partial function was applied to
* @p args, false otherwise.
* @note This member function can return @p false even if
* @brief Returns a value if @p arg was matched by one of the
* handler of this behavior, returns @p nothing otherwise.
* @note This member function can return @p nothing even if
* {@link defined_at()} returns @p true, because {@link defined_at()}
* does <b>not</b> evaluate guards.
* does not evaluate guards.
*/
template<typename T>
inline optional<any_tuple> operator()(T&& arg);
......
......@@ -109,7 +109,10 @@ class context_switching_resume {
}
break;
}
default: { CPPA_CRITICAL("illegal state"); }
case yield_state::invalid: {
// must not happen
CPPA_CRITICAL("illegal state");
}
}
}
}
......
......@@ -122,7 +122,9 @@ class cooperative_scheduling {
}
break;
}
default: return;
case actor_state::ready:
case actor_state::done:
return;
}
}
break;
......@@ -134,7 +136,9 @@ class cooperative_scheduling {
}
break;
}
default: break;
case intrusive::enqueued:
// enqueued to an running actors' mailbox; nothing to do
break;
}
}
......
......@@ -141,7 +141,7 @@ class event_based_resume {
std::atomic_thread_fence(std::memory_order_seq_cst);
if (!d->has_next_message()) {
switch (d->cas_state(actor_state::about_to_block,
actor_state::blocked)) {
actor_state::blocked)) {
case actor_state::ready:
// interrupted by arriving message
// restore members
......@@ -154,9 +154,16 @@ class event_based_resume {
"to blocked");
// done setting actor to blocked
return resumable::resume_later;
default:
CPPA_LOG_ERROR("invalid state");
CPPA_CRITICAL("invalid state");
case actor_state::about_to_block:
CPPA_CRITICAL("attempt to set state from "
"about_to_block to blocked "
"failed: state is still set "
"to about_to_block");
case actor_state::done:
CPPA_CRITICAL("attempt to set state from "
"about_to_block to blocked "
"failed: state is set "
"to done");
};
}
else {
......
......@@ -63,7 +63,6 @@ enum receive_policy_flag {
};
enum handle_message_result {
hm_timeout_msg,
hm_skip_msg,
hm_drop_msg,
hm_cache_msg,
......@@ -112,9 +111,6 @@ class invoke_policy {
reset_pointer = false;
break;
}
default: {
CPPA_CRITICAL("illegal result of handle_message");
}
}
if (reset_pointer) node_ptr.reset();
return result;
......@@ -296,10 +292,6 @@ class invoke_policy {
return hm_skip_msg;
}
switch (this->filter_msg(self, node)) {
default: {
CPPA_LOG_ERROR("illegal filter result");
CPPA_CRITICAL("illegal filter result");
}
case normal_exit_signal: {
CPPA_LOG_DEBUG("dropped normal exit signal");
return hm_drop_msg;
......@@ -334,7 +326,7 @@ class invoke_policy {
}
case timeout_response_message: {
handle_sync_failure_on_mismatch = false;
// fall through
CPPA_ANNOTATE_FALLTHROUGH;
}
case sync_response: {
CPPA_LOG_DEBUG("handle as synchronous response: "
......
......@@ -87,20 +87,23 @@ class no_scheduling {
any_tuple& msg, execution_unit*) {
auto ptr = self->new_mailbox_element(hdr, std::move(msg));
switch (self->mailbox().enqueue(ptr)) {
default:
break;
case intrusive::first_enqueued: {
lock_type guard(m_mtx);
self->set_state(actor_state::ready);
m_cv.notify_one();
break;
}
case intrusive::queue_closed:
case intrusive::queue_closed: {
if (hdr.id.valid()) {
detail::sync_request_bouncer f{self->exit_reason()};
f(hdr.sender, hdr.id);
}
break;
}
case intrusive::enqueued: {
// enqueued to a running actor's mailbox; nothing to do
break;
}
}
}
......
......@@ -304,7 +304,6 @@ T& get_ref(primitive_variant& pv) {
* @ingroup TypeSystem
* @brief Casts a primitive variant to its C++ type.
* @relates primitive_variant
* @tparam T C++ type equivalent of @p PT.
* @param pv A primitive variant of type @p T.
* @returns A const reference to the value of @p pv of type @p T.
*/
......@@ -319,7 +318,6 @@ get(const primitive_variant& pv) {
* @ingroup TypeSystem
* @brief Casts a non-const primitive variant to its C++ type.
* @relates primitive_variant
* @tparam T C++ type equivalent of @p PT.
* @param pv A primitive variant of type @p T.
* @returns A reference to the value of @p pv of type @p T.
*/
......
......@@ -51,6 +51,8 @@ class ref_counted : public memory_managed {
ref_counted();
~ref_counted();
/**
* @brief Increases reference count by one.
*/
......
......@@ -47,7 +47,7 @@ class scoped_actor {
scoped_actor(const scoped_actor&) = delete;
explicit scoped_actor(bool hidden);
explicit scoped_actor(bool hide_actor);
~scoped_actor();
......@@ -81,7 +81,7 @@ class scoped_actor {
private:
void init(bool hidden);
void init(bool hide_actor);
bool m_hidden;
actor_id m_prev; // used for logging/debugging purposes only
......
......@@ -63,11 +63,9 @@ class serializer {
virtual ~serializer();
/**
* @brief Begins serialization of an object of the type
* named @p type_name.
* @param type_name The platform-independent @p libcppa type name.
* @brief Begins serialization of an object of type @p uti.
*/
virtual void begin_object(const uniform_type_info*) = 0;
virtual void begin_object(const uniform_type_info* uti) = 0;
/**
* @brief Ends serialization of an object.
......
......@@ -186,7 +186,7 @@ actor spawn_functor(execution_unit* eu,
/**
* @brief Spawns an actor of type @p C.
* @param args Constructor arguments.
* @tparam C Subtype of {@link event_based_actor} or {@link sb_actor}.
* @tparam Impl Subtype of {@link event_based_actor} or {@link sb_actor}.
* @tparam Os Optional flags to modify <tt>spawn</tt>'s behavior.
* @returns An {@link actor} to the spawned {@link actor}.
*/
......@@ -212,7 +212,7 @@ actor spawn(Ts&&... args) {
/**
* @brief Spawns an actor of type @p C that immediately joins @p grp.
* @param args Constructor arguments.
* @tparam C Subtype of {@link event_based_actor} or {@link sb_actor}.
* @tparam Impl Subtype of {@link event_based_actor} or {@link sb_actor}.
* @tparam Os Optional flags to modify <tt>spawn</tt>'s behavior.
* @returns An {@link actor} to the spawned {@link actor}.
* @note The spawned has joined the group before this function returns.
......
......@@ -56,7 +56,7 @@ class sync_sender_impl : public Base {
/**
* @brief Sends @p what as a synchronous message to @p whom.
* @param whom Receiver of the message.
* @param dest Receiver of the message.
* @param what Message content as tuple.
* @returns A handle identifying a future to the response of @p whom.
* @warning The returned handle is actor specific and the response to the
......@@ -76,7 +76,7 @@ class sync_sender_impl : public Base {
/**
* @brief Sends <tt>{what...}</tt> as a synchronous message to @p whom.
* @param whom Receiver of the message.
* @param dest Receiver of the message.
* @param what Message elements.
* @returns A handle identifying a future to the response of @p whom.
* @warning The returned handle is actor specific and the response to the
......
......@@ -229,7 +229,7 @@ class uniform_type_info {
/**
* @brief Deserializes @p instance from @p source.
* @param instance Instance of this type.
* @param sink Data source.
* @param source Data source.
* @pre @p instance has the type of @p this.
*/
virtual void deserialize(void* instance, deserializer* source) const = 0;
......
......@@ -47,7 +47,8 @@ enum buffer_write_policy {
};
/**
* @brief
* @brief A buffer implementation with configurable final size
* that also supports dynamic growing if needed.
*/
class buffer {
......
......@@ -41,57 +41,79 @@ namespace cppa { namespace util {
* @brief SI time units to specify timeouts.
*/
enum class time_unit : std::uint32_t {
none = 0,
invalid = 0,
seconds = 1,
milliseconds = 1000,
microseconds = 1000000
};
// minutes are implicitly converted to seconds
template<std::intmax_t Num, std::intmax_t Denom>
struct ratio_to_time_unit_helper {
static constexpr time_unit value = time_unit::invalid;
};
template<> struct ratio_to_time_unit_helper<1, 1> {
static constexpr time_unit value = time_unit::seconds;
};
template<> struct ratio_to_time_unit_helper<1, 1000> {
static constexpr time_unit value = time_unit::milliseconds;
};
template<> struct ratio_to_time_unit_helper<1, 1000000> {
static constexpr time_unit value = time_unit::microseconds;
};
template<> struct ratio_to_time_unit_helper<60, 1> {
static constexpr time_unit value = time_unit::seconds;
};
/**
* @brief Converts an STL time period to a
* {@link cppa::util::time_unit time_unit}.
*/
template<typename Period>
constexpr time_unit get_time_unit_from_period() {
return (Period::num != 1
? time_unit::none
: (Period::den == 1
? time_unit::seconds
: (Period::den == 1000
? time_unit::milliseconds
: (Period::den == 1000000
? time_unit::microseconds
: time_unit::none))));
return ratio_to_time_unit_helper<Period::num, Period::den>::value;
}
/**
* @brief Time duration consisting of a {@link cppa::util::time_unit time_unit}
* and a 32 bit unsigned integer.
* and a 64 bit unsigned integer.
*/
class duration {
public:
constexpr duration() : unit(time_unit::none), count(0) { }
constexpr duration() : unit(time_unit::invalid), count(0) { }
constexpr duration(time_unit u, std::uint32_t v) : unit(u), count(v) { }
/**
* @brief Creates a new instance from an STL duration.
* @throws std::invalid_argument Thrown if <tt>d.count()</tt> is negative.
*/
template<class Rep, class Period>
constexpr duration(std::chrono::duration<Rep, Period> d)
: unit(get_time_unit_from_period<Period>()), count(d.count()) {
static_assert(get_time_unit_from_period<Period>() != time_unit::none,
"only seconds, milliseconds or microseconds allowed");
duration(std::chrono::duration<Rep, Period> d)
: unit(get_time_unit_from_period<Period>()), count(rd(d)) {
static_assert(get_time_unit_from_period<Period>() != time_unit::invalid,
"cppa::duration supports only minutes, seconds, "
"milliseconds or microseconds");
}
// convert minutes to seconds
/**
* @brief Creates a new instance from an STL duration given in minutes.
* @throws std::invalid_argument Thrown if <tt>d.count()</tt> is negative.
*/
template<class Rep>
constexpr duration(std::chrono::duration<Rep, std::ratio<60, 1> > d)
: unit(time_unit::seconds), count(d.count() * 60) { }
duration(std::chrono::duration<Rep, std::ratio<60, 1> > d)
: unit(time_unit::seconds), count(rd(d) * 60) { }
/**
* @brief Returns true if <tt>unit != time_unit::none</tt>.
*/
inline bool valid() const { return unit != time_unit::none; }
inline bool valid() const { return unit != time_unit::invalid; }
/**
* @brief Returns true if <tt>count == 0</tt>.
......@@ -102,7 +124,27 @@ class duration {
time_unit unit;
std::uint32_t count;
std::uint64_t count;
private:
// reads d.count and throws invalid_argument if d.count < 0
template<class Rep, class Period>
static inline std::uint64_t
rd(const std::chrono::duration<Rep, Period>& d) {
if (d.count() < 0) {
throw std::invalid_argument("negative durations are not supported");
}
return static_cast<std::uint64_t>(d.count());
}
template<class Rep>
static inline std::uint64_t
rd(const std::chrono::duration<Rep, std::ratio<60, 1>>& d) {
// convert minutes to seconds on-the-fly
return rd(std::chrono::duration<Rep, std::ratio<1, 1>>(d.count()) * 60);
}
};
......@@ -140,7 +182,8 @@ operator+=(std::chrono::time_point<Clock, Duration>& lhs,
lhs += std::chrono::microseconds(rhs.count);
break;
default: break;
case cppa::util::time_unit::invalid:
break;
}
return lhs;
}
......
......@@ -59,7 +59,7 @@ void pt_dispatch(primitive_type ptype, Fun&& f) {
case pt_u16string: f(pt_token<pt_u16string>()); break;
case pt_u32string: f(pt_token<pt_u32string>()); break;
case pt_atom: f(pt_token<pt_atom>()); break;
default: break;
case pt_null: break; // nothing to do
}
}
......
......@@ -47,6 +47,8 @@ class weak_ptr_anchor : public ref_counted {
public:
~weak_ptr_anchor();
weak_ptr_anchor(ref_counted* ptr);
/**
......
......@@ -81,8 +81,12 @@ struct group_nameserver : event_based_actor {
}
);
}
~group_nameserver();
};
// avoid weak-vtables warning by providing dtor out-of-line
group_nameserver::~group_nameserver() { }
void publish_local_groups(std::uint16_t port, const char* addr) {
auto gn = spawn<group_nameserver, hidden>();
try {
......@@ -96,4 +100,8 @@ void publish_local_groups(std::uint16_t port, const char* addr) {
}
}
abstract_group::module::~module() { }
abstract_group::~abstract_group() { }
} // namespace cppa
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#include "cppa/io/acceptor.hpp"
namespace cppa {
namespace io {
acceptor::~acceptor() { }
} // namespace io
} // namespace cppa
......@@ -48,6 +48,8 @@ using namespace std;
namespace cppa {
actor_proxy::~actor_proxy() { }
actor_proxy::actor_proxy(actor_id mid) : super(mid) {
m_node = get_middleman()->node();
}
......
......@@ -49,6 +49,8 @@ typedef cppa::util::upgrade_lock_guard<cppa::util::shared_spinlock> upgrade_guar
namespace cppa { namespace detail {
actor_registry::~actor_registry() { }
actor_registry::actor_registry() : m_running(0), m_ids(1) { }
actor_registry::value_type actor_registry::get_entry(actor_id key) const {
......
......@@ -43,6 +43,8 @@ class continuation_decorator : public detail::behavior_impl {
typedef typename behavior_impl::pointer pointer;
~continuation_decorator();
continuation_decorator(continuation_fun fun, pointer ptr)
: super(ptr->timeout()), m_fun(fun), m_decorated(std::move(ptr)) {
CPPA_REQUIRE(m_decorated != nullptr);
......@@ -80,6 +82,9 @@ class continuation_decorator : public detail::behavior_impl {
};
// avoid weak-vtables warning by providing dtor out-of-line
continuation_decorator::~continuation_decorator() { }
behavior::behavior(const partial_function& fun) : m_impl(fun.m_impl) { }
behavior behavior::add_continuation(continuation_fun fun) {
......
......@@ -110,6 +110,8 @@ class broker::servant : public continuable {
public:
~servant();
template<typename... Ts>
servant(broker_ptr parent, Ts&&... args)
: super{std::forward<Ts>(args)...}, m_disconnected{false}
......@@ -153,12 +155,17 @@ class broker::servant : public continuable {
};
// avoid weak-vtables warning by providing dtor out-of-line
broker::servant::~servant() { }
class broker::scribe : public extend<broker::servant>::with<buffered_writing> {
typedef combined_type super;
public:
~scribe();
scribe(broker_ptr parent, input_stream_ptr in, output_stream_ptr out)
: super{get_middleman(), out, move(parent), in->read_handle(), out->write_handle()}
, m_is_continue_reading{false}, m_dirty{false}
......@@ -185,7 +192,7 @@ class broker::scribe : public extend<broker::servant>::with<buffered_writing> {
for (;;) {
// stop reading if actor finished execution
if (m_broker->exit_reason() != exit_reason::not_exited) {
return read_closed;
return continue_reading_result::closed;
}
auto& buf = get_ref<2>(m_read_msg);
if (m_dirty) {
......@@ -199,12 +206,12 @@ class broker::scribe : public extend<broker::servant>::with<buffered_writing> {
try { buf.append_from(m_in.get()); }
catch (std::ios_base::failure&) {
disconnect();
return read_failure;
return continue_reading_result::failure;
}
CPPA_LOG_DEBUG("received " << (buf.size() - before) << " bytes");
if ( before == buf.size()
|| (m_policy == broker::exactly && buf.size() != m_policy_buffer_size)) {
return read_continue_later;
return continue_reading_result::continue_later;
}
if ( ( m_policy == broker::at_least
&& buf.size() >= m_policy_buffer_size)
......@@ -240,12 +247,17 @@ class broker::scribe : public extend<broker::servant>::with<buffered_writing> {
};
// avoid weak-vtables warning by providing dtor out-of-line
broker::scribe::~scribe() { }
class broker::doorman : public broker::servant {
typedef servant super;
public:
~doorman();
doorman(broker_ptr parent, acceptor_uptr ptr)
: super{move(parent), ptr->file_handle()}
, m_accept_msg{atom("IO_accept"),
......@@ -261,7 +273,7 @@ class broker::doorman : public broker::servant {
catch (std::exception& e) {
CPPA_LOG_ERROR(to_verbose_string(e));
static_cast<void>(e); // keep compiler happy
return read_failure;
return continue_reading_result::failure;
}
if (opt) {
using namespace std;
......@@ -270,7 +282,7 @@ class broker::doorman : public broker::servant {
move(p.second));
m_broker->invoke_message({invalid_actor_addr, nullptr}, m_accept_msg);
}
else return read_continue_later;
else return continue_reading_result::continue_later;
}
}
......@@ -288,6 +300,9 @@ class broker::doorman : public broker::servant {
};
// avoid weak-vtables warning by providing dtor out-of-line
broker::doorman::~doorman() { }
void broker::invoke_message(msg_hdr_cref hdr, any_tuple msg) {
CPPA_LOG_TRACE(CPPA_TARG(msg, to_string));
if (planned_exit_reason() != exit_reason::not_exited || bhvr_stack().empty()) {
......@@ -327,7 +342,6 @@ void broker::invoke_message(msg_hdr_cref hdr, any_tuple msg) {
m_priority_policy.push_to_cache(unique_mailbox_element_pointer{e});
break;
}
default: CPPA_CRITICAL("illegal result of handle_message");
}
}
catch (std::exception& e) {
......
......@@ -40,11 +40,11 @@ continuable::continuable(native_socket_type rd, native_socket_type wr)
: m_rd(rd), m_wr(wr) { }
continue_reading_result continuable::continue_reading() {
return read_closed;
return continue_reading_result::closed;
}
continue_writing_result continuable::continue_writing() {
return write_closed;
return continue_writing_result::closed;
}
} } // namespace cppa::network
......@@ -31,6 +31,8 @@
#include <cstdint>
#include <stdexcept>
#include "cppa/config.hpp"
#include "cppa/detail/cs_thread.hpp"
namespace {
......@@ -75,12 +77,14 @@ const bool cs_thread::is_disabled_feature = true;
# include <valgrind/valgrind.h>
#endif
CPPA_PUSH_WARNINGS
// boost includes
#include <boost/version.hpp>
#include <boost/context/all.hpp>
#if BOOST_VERSION >= 105300
# include <boost/coroutine/all.hpp>
#endif
CPPA_POP_WARNINGS
namespace cppa { namespace detail {
......@@ -88,7 +92,7 @@ void cst_trampoline(intptr_t iptr);
namespace {
#if CPPA_ANNOTATE_VALGRIND
#ifdef CPPA_ANNOTATE_VALGRIND
typedef int vg_member;
inline void vg_register(vg_member& stack_id, vptr ptr1, vptr ptr2) {
stack_id = VALGRIND_STACK_REGISTER(ptr1, ptr2);
......@@ -154,7 +158,8 @@ namespace {
ctx_stack_info new_stack(context& ctx,
stack_allocator& alloc,
vg_member& vgm) {
size_t mss = ctxn::minimum_stacksize() * stack_multiplier;
auto mss = static_cast<intptr_t>( ctxn::minimum_stacksize()
* stack_multiplier);
ctx.fc_stack.base = alloc.allocate(mss);
ctx.fc_stack.limit = reinterpret_cast<vptr>(
reinterpret_cast<intptr_t>(ctx.fc_stack.base) - mss);
......@@ -190,7 +195,8 @@ namespace {
ctx_stack_info new_stack(context& ctx,
stack_allocator& alloc,
vg_member& vgm) {
size_t mss = stack_allocator::minimum_stacksize() * stack_multiplier;
auto mss = static_cast<intptr_t>( stack_allocator::minimum_stacksize()
* stack_multiplier);
ctx = ctxn::make_fcontext(alloc.allocate(mss), mss, cst_trampoline);
vg_register(vgm,
ctx->fc_stack.sp,
......@@ -219,9 +225,10 @@ namespace {
ctx_stack_info new_stack(context& ctx,
stack_allocator& alloc,
vg_member& vgm) {
size_t mss = stack_allocator::minimum_stacksize() * stack_multiplier;
auto mss = static_cast<intptr_t>( stack_allocator::minimum_stacksize()
* stack_multiplier);
ctx_stack_info sinf;
alloc.allocate(sinf, mss);
alloc.allocate(sinf, static_cast<size_t>(mss));
ctx = ctxn::make_fcontext(sinf.sp, sinf.size, cst_trampoline);
vg_register(vgm,
ctx->fc_stack.sp,
......@@ -244,7 +251,7 @@ struct cst_impl {
cst_impl() : m_ctx() { }
virtual ~cst_impl() { }
virtual ~cst_impl();
virtual void run() = 0;
......@@ -256,9 +263,14 @@ struct cst_impl {
};
// avoid weak-vtables warning by providing dtor out-of-line
cst_impl::~cst_impl() { }
// a cs_thread representing a thread ('converts' the thread to a cs_thread)
struct converted_cs_thread : cst_impl {
~converted_cs_thread();
converted_cs_thread() {
init_converted_context(m_converted, m_ctx);
}
......@@ -271,6 +283,9 @@ struct converted_cs_thread : cst_impl {
};
// avoid weak-vtables warning by providing dtor out-of-line
converted_cs_thread::~converted_cs_thread() { }
// a cs_thread executing a function
struct fun_cs_thread : cst_impl {
......@@ -278,9 +293,7 @@ struct fun_cs_thread : cst_impl {
m_stack_info = new_stack(m_ctx, m_alloc, m_vgm);
}
~fun_cs_thread() {
del_stack(m_alloc, m_stack_info, m_vgm);
}
~fun_cs_thread();
void run() override {
m_fun(m_arg);
......@@ -294,6 +307,11 @@ struct fun_cs_thread : cst_impl {
};
// avoid weak-vtables warning by providing dtor out-of-line
fun_cs_thread::~fun_cs_thread() {
del_stack(m_alloc, m_stack_info, m_vgm);
}
void cst_trampoline(intptr_t iptr) {
auto ptr = (cst_impl*) iptr;
ptr->run();
......
......@@ -48,11 +48,11 @@ bool operator==(const duration& lhs, const duration& rhs) {
}
std::string duration::to_string() const {
if (unit == time_unit::none) return "-invalid-";
if (unit == time_unit::invalid) return "-invalid-";
std::ostringstream oss;
oss << count;
switch (unit) {
default: oss << "???"; break;
case time_unit::invalid: oss << "?"; break;
case time_unit::seconds: oss << "s"; break;
case time_unit::milliseconds: oss << "ms"; break;
case time_unit::microseconds: oss << "us"; break;
......
......@@ -39,6 +39,8 @@ event_based_actor::event_based_actor() {
m_state = actor_state::blocked;
}
event_based_actor::~event_based_actor() { }
void event_based_actor::forward_to(const actor& whom) {
forward_message(whom, message_priority::normal);
}
......
......@@ -78,23 +78,27 @@ std::string be_what(int err_code) {
namespace cppa {
cppa_exception::~cppa_exception() { }
cppa_exception::cppa_exception(const std::string& what_str)
: m_what(what_str) { }
cppa_exception::cppa_exception(std::string&& what_str)
: m_what(std::move(what_str)) { }
cppa_exception::~cppa_exception() throw() { }
const char* cppa_exception::what() const throw() {
const char* cppa_exception::what() const noexcept {
return m_what.c_str();
}
actor_exited::~actor_exited() { }
actor_exited::actor_exited(std::uint32_t reason)
: cppa_exception(ae_what(reason)) {
m_reason = reason;
}
network_error::~network_error() { }
network_error::network_error(const std::string& str) : cppa_exception(str) { }
network_error::network_error(std::string&& str)
......@@ -104,4 +108,6 @@ bind_failure::bind_failure(int err_code) : network_error(be_what(err_code)) {
m_errno = err_code;
}
bind_failure::~bind_failure() { }
} // namespace cppa
......@@ -58,8 +58,8 @@
namespace cppa { namespace detail { namespace fd_util {
void throw_io_failure(const char* what, bool add_errno_failure) {
if (add_errno_failure) {
void throw_io_failure [[noreturn]] (const char* what, bool add_errno) {
if (add_errno) {
std::ostringstream oss;
oss << what << ": " << last_socket_error_as_string()
<< " [errno: " << last_socket_error() << "]";
......
......@@ -38,7 +38,7 @@ std::vector<std::string> get_mac_addresses() {
size_t buf_size = 0;
for (auto i = indices; !(i->if_index == 0 && i->if_name == nullptr); ++i) {
mib[5] = i->if_index;
mib[5] = static_cast<int>(i->if_index);
size_t len;
if (sysctl(mib, 6, nullptr, &len, nullptr, 0) < 0) {
......@@ -60,7 +60,7 @@ std::vector<std::string> get_mac_addresses() {
auto sdl = reinterpret_cast<sockaddr_dl*>(ifm + 1);
auto ptr = reinterpret_cast<unsigned char*>(LLADDR(sdl));
auto ctoi = [](char c) -> unsigned {
auto uctoi = [](unsigned char c) -> unsigned {
return static_cast<unsigned char>(c);
};
......@@ -68,11 +68,11 @@ std::vector<std::string> get_mac_addresses() {
oss << std::hex;
oss.fill('0');
oss.width(2);
oss << ctoi(*ptr++);
oss << uctoi(*ptr++);
for (auto j = 0; j < 5; ++j) {
oss << ":";
oss.width(2);
oss << ctoi(*ptr++);
oss << uctoi(*ptr++);
}
auto addr = oss.str();
if (addr != "00:00:00:00:00:00") result.push_back(std::move(addr));
......
......@@ -591,6 +591,8 @@ atomic<size_t> m_ad_hoc_id;
namespace cppa { namespace detail {
group_manager::~group_manager() { }
group_manager::group_manager() {
abstract_group::unique_module_ptr ptr(new local_group_module);
m_mmap.insert(make_pair(string("local"), move(ptr)));
......
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#include "cppa/io/input_stream.hpp"
namespace cppa {
namespace io {
input_stream::~input_stream() { }
} // namespace io
} // namespace cppa
......@@ -77,16 +77,12 @@ class logging_impl : public logging {
public:
void initialize() {
const char* log_level_lookup_table[] = {
"ERROR", "WARN", "INFO", "DEBUG", "TRACE"
};
m_thread = thread([this] { (*this)(); });
std::string msg = "ENTRY log level = ";
switch (CPPA_LOG_LEVEL) {
default: msg += "????"; break;
case 0: msg += "ERROR"; break;
case 1: msg += "WARN"; break;
case 2: msg += "INFO"; break;
case 3: msg += "DEBUG"; break;
case 4: msg += "TRACE"; break;
}
msg += log_level_lookup_table[CPPA_LOG_LEVEL];
log("TRACE", "logging", "run", __FILE__, __LINE__, msg);
}
......
......@@ -33,6 +33,9 @@
namespace cppa {
mailbox_element::mailbox_element(msg_hdr_cref hdr, any_tuple data)
: next(nullptr), marked(false), sender(hdr.sender), msg(std::move(data)), mid(hdr.id) { }
: next(nullptr), marked(false), sender(hdr.sender)
, msg(std::move(data)), mid(hdr.id) { }
mailbox_element::~mailbox_element() { }
} // namespace cppa
......@@ -172,6 +172,8 @@ class middleman_impl : public middleman {
middleman_impl() : m_done(false) { }
~middleman_impl();
void run_later(function<void()> fun) override {
m_queue.enqueue(new middleman_event(move(fun)));
atomic_thread_fence(memory_order_seq_cst);
......@@ -337,7 +339,7 @@ class middleman_impl : public middleman {
+ util::get_root_uuid();
cppa::node_id::host_id_type node_id;
ripemd_160(node_id, hd_serial_and_mac_addr);
return new cppa::node_id(getpid(), node_id);
return new cppa::node_id(static_cast<uint32_t>(getpid()), node_id);
}
inline void quit() { m_done = true; }
......@@ -363,6 +365,9 @@ class middleman_impl : public middleman {
};
// avoid weak-vtables warning by providing dtor out-of-line
middleman_impl::~middleman_impl() { }
class middleman_overseer : public continuable {
typedef continuable super;
......@@ -372,6 +377,8 @@ class middleman_overseer : public continuable {
middleman_overseer(native_socket_type pipe_fd, middleman_queue& q)
: super(pipe_fd), m_queue(q) { }
~middleman_overseer();
void dispose() override {
delete this;
}
......@@ -392,7 +399,7 @@ class middleman_overseer : public continuable {
CPPA_LOGF_DEBUG("execute run_later functor");
(*msg)();
}
return read_continue_later;
return continue_reading_result::continue_later;
}
void io_failed(event_bitmask) override {
......@@ -405,6 +412,9 @@ class middleman_overseer : public continuable {
};
// avoid weak-vtables warning by providing dtor out-of-line
middleman_overseer::~middleman_overseer() { }
middleman::~middleman() { }
void middleman_loop(middleman_impl* impl) {
......@@ -425,33 +435,39 @@ void middleman_loop(middleman_impl* impl) {
case event::write: {
CPPA_LOGF_DEBUG("handle event::write for " << io);
switch (io->continue_writing()) {
case read_failure:
case continue_writing_result::failure:
io->io_failed(event::write);
// fall through
case write_closed:
CPPA_ANNOTATE_FALLTHROUGH;
case continue_writing_result::closed:
impl->stop_writer(io);
CPPA_LOGF_DEBUG("writer removed because of error");
CPPA_LOGF_DEBUG("writer removed because "
"of error write_closed or ");
break;
case write_done:
case continue_writing_result::done:
impl->stop_writer(io);
break;
default: break;
case continue_writing_result::continue_later:
// leave
break;
}
if (mask == event::write) break;
// else: fall through
CPPA_LOGF_DEBUG("handle event::both; fall through");
CPPA_ANNOTATE_FALLTHROUGH;
}
case event::read: {
CPPA_LOGF_DEBUG("handle event::read for " << io);
switch (io->continue_reading()) {
case read_failure:
case continue_reading_result::failure:
io->io_failed(event::read);
// fall through
case read_closed:
CPPA_ANNOTATE_FALLTHROUGH;
case continue_reading_result::closed:
impl->stop_reader(io);
CPPA_LOGF_DEBUG("remove peer");
break;
default: break;
case continue_reading_result::continue_later:
// nothing to do
break;
}
break;
}
......@@ -480,14 +496,16 @@ void middleman_loop(middleman_impl* impl) {
case event::both:
case event::write:
switch (io->continue_writing()) {
case write_failure:
case continue_writing_result::failure:
io->io_failed(event::write);
// fall through
case write_closed:
case write_done:
CPPA_ANNOTATE_FALLTHROUGH;
case continue_writing_result::closed:
case continue_writing_result::done:
handler->erase_later(io, event::write);
break;
default: break;
case continue_writing_result::continue_later:
// nothing to do
break;
}
break;
case event::error:
......
......@@ -34,7 +34,7 @@
#ifndef CPPA_WINDOWS
#include <poll.h>
#define SOCKERR errno
#define SOCKERR errno
#else
# include <ws2tcpip.h>
# include <ws2ipdef.h>
......@@ -87,10 +87,12 @@ class middleman_event_handler_impl : public middleman_event_handler {
CPPA_REQUIRE(m_pollset.size() == m_meta.size());
int presult = -1;
while (presult < 0) {
#ifdef CPPA_WINDOWS
#ifdef CPPA_WINDOWS
presult = ::WSAPoll(m_pollset.data(), m_pollset.size(), -1);
#else
presult = ::poll(m_pollset.data(), m_pollset.size(), -1);
presult = ::poll(m_pollset.data(),
static_cast<nfds_t>(m_pollset.size()),
-1);
#endif
CPPA_LOG_DEBUG("poll() on " << num_sockets()
<< " sockets returned " << presult);
......
......@@ -106,6 +106,8 @@ bool equal(const std::string& hash,
return true;
}
node_id::~node_id() { }
node_id::node_id(const node_id& other)
: super(), m_process_id(other.process_id()), m_host_id(other.host_id()) { }
......
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#include "cppa/io/output_stream.hpp"
namespace cppa {
namespace io {
output_stream::~output_stream() { }
} // namespace io
} // namespace cppa
......@@ -99,9 +99,12 @@ continue_reading_result peer::continue_reading() {
for (;;) {
try { m_rd_buf.append_from(m_in.get()); }
catch (exception&) {
return read_failure;
return continue_reading_result::failure;
}
if (!m_rd_buf.full()) {
// try again later
return continue_reading_result::continue_later;
}
if (!m_rd_buf.full()) return read_continue_later; // try again later
switch (m_state) {
case wait_for_process_info: {
//DEBUG("peer_connection::continue_reading: "
......@@ -116,13 +119,13 @@ continue_reading_result peer::continue_reading() {
std::cerr << "*** middleman warning: "
"incoming connection from self"
<< std::endl;
return read_failure;
return continue_reading_result::failure;
}
CPPA_LOG_DEBUG("read process info: " << to_string(*m_node));
if (!parent()->register_peer(*m_node, this)) {
CPPA_LOG_ERROR("multiple incoming connections "
"from the same node");
return read_failure;
return continue_reading_result::failure;
}
// initialization done
m_state = wait_for_msg_size;
......@@ -153,7 +156,7 @@ continue_reading_result peer::continue_reading() {
CPPA_LOG_ERROR("exception during read_message: "
<< detail::demangle(typeid(e))
<< ", what(): " << e.what());
return read_failure;
return continue_reading_result::failure;
}
CPPA_LOG_DEBUG("deserialized: " << to_string(hdr) << " " << to_string(msg));
match(msg) (
......@@ -186,9 +189,6 @@ continue_reading_result peer::continue_reading() {
m_state = wait_for_msg_size;
break;
}
default: {
CPPA_CRITICAL("illegal state");
}
}
// try to read more (next iteration)
}
......@@ -338,12 +338,14 @@ void peer::unlink(const actor_addr& lhs, const actor_addr& rhs) {
continue_writing_result peer::continue_writing() {
CPPA_LOG_TRACE("");
auto result = super::continue_writing();
while (result == write_done && !queue().empty()) {
while (result == continue_writing_result::done && !queue().empty()) {
auto tmp = queue().pop();
enqueue(tmp.first, tmp.second);
result = super::continue_writing();
}
if (result == write_done && stop_on_last_proxy_exited() && !has_unwritten_data()) {
if (result == continue_writing_result::done
&& stop_on_last_proxy_exited()
&& !has_unwritten_data()) {
if (parent()->get_namespace().count_proxies(*m_node) == 0) {
parent()->last_proxy_exited(this);
}
......@@ -367,7 +369,7 @@ void peer::enqueue_impl(msg_hdr_cref hdr, const any_tuple& msg) {
add_type_if_needed((tname) ? *tname : detail::get_tuple_type_names(*msg.vals()));
uint32_t size = 0;
auto& wbuf = write_buffer();
auto before = wbuf.size();
auto before = static_cast<uint32_t>(wbuf.size());
binary_serializer bs(&wbuf, &(parent()->get_namespace()), &m_outgoing_types);
wbuf.write(sizeof(uint32_t), &size);
try { bs << hdr << msg; }
......@@ -379,7 +381,8 @@ void peer::enqueue_impl(msg_hdr_cref hdr, const any_tuple& msg) {
return;
}
CPPA_LOG_DEBUG("serialized: " << to_string(hdr) << " " << to_string(msg));
size = (wbuf.size() - before) - sizeof(std::uint32_t);
size = static_cast<std::uint32_t>((wbuf.size() - before))
- static_cast<std::uint32_t>(sizeof(std::uint32_t));
// update size in buffer
memcpy(wbuf.offset_data(before), &size, sizeof(std::uint32_t));
}
......
......@@ -59,7 +59,7 @@ continue_reading_result peer_acceptor::continue_reading() {
catch (exception& e) {
CPPA_LOG_ERROR(to_verbose_string(e));
static_cast<void>(e); // keep compiler happy
return read_failure;
return continue_reading_result::failure;
}
if (opt) {
auto& pair = *opt;
......@@ -89,7 +89,7 @@ continue_reading_result peer_acceptor::continue_reading() {
<< endl;
}
}
else return read_continue_later;
else return continue_reading_result::continue_later;
}
}
......
......@@ -35,4 +35,7 @@ namespace cppa {
ref_counted::ref_counted() : m_rc(0) { }
ref_counted::~ref_counted() { }
} // namespace cppa
......@@ -48,6 +48,8 @@ inline sync_request_info* new_req_info(actor_addr sptr, message_id id) {
return detail::memory::create<sync_request_info>(std::move(sptr), id);
}
sync_request_info::~sync_request_info() { }
sync_request_info::sync_request_info(actor_addr sptr, message_id id)
: next(nullptr), sender(std::move(sptr)), mid(id) {
}
......@@ -117,7 +119,14 @@ void remote_actor_proxy::forward_msg(msg_hdr_cref hdr, any_tuple msg) {
});
return; // no need to forward message
}
default: break;
case intrusive::enqueued: {
CPPA_LOG_DEBUG("enqueued pending request to non-empty queue");
break;
}
case intrusive::first_enqueued: {
CPPA_LOG_DEBUG("enqueued pending request to empty queue");
break;
}
}
}
auto node = m_node;
......
......@@ -394,7 +394,7 @@ void ripemd_160(std::array<std::uint8_t, 20>& storage, const std::string& data)
// initialize
MDinit(MDbuf);
length = data.size();
length = static_cast<dword>(data.size());
// process message in 16-word chunks
for (dword nbytes = length; nbytes > 63; nbytes -= 64) {
......@@ -410,10 +410,11 @@ void ripemd_160(std::array<std::uint8_t, 20>& storage, const std::string& data)
MDfinish(MDbuf, message, length, 0);
for (size_t i = 0; i < storage.size(); i += 4) {
storage[i] = MDbuf[i>>2]; // implicit cast to byte
storage[i+1] = (MDbuf[i>>2] >> 8); // extracts the 8 least
storage[i+2] = (MDbuf[i>>2] >> 16); // significant bits.
storage[i+3] = (MDbuf[i>>2] >> 24);
// extracts the 8 least significant bits by casting to byte
storage[i] = static_cast<uint8_t>(MDbuf[i>>2] );
storage[i+1] = static_cast<uint8_t>(MDbuf[i>>2] >> 8);
storage[i+2] = static_cast<uint8_t>(MDbuf[i>>2] >> 16);
storage[i+3] = static_cast<uint8_t>(MDbuf[i>>2] >> 24);
}
}
......
......@@ -259,7 +259,7 @@ class coordinator::shutdown_helper : public resumable {
};
// get rid of weak-vtables warning by providing dtor out-of-line
// avoid weak-vtables warning by providing dtor out-of-line
coordinator::shutdown_helper::~shutdown_helper() { }
void coordinator::initialize() {
......
......@@ -54,8 +54,8 @@ blocking_actor* alloc() {
} // namespace <anonymous>
void scoped_actor::init(bool hidden) {
m_hidden = hidden;
void scoped_actor::init(bool hide_actor) {
m_hidden = hide_actor;
m_self.reset(alloc());
if (!m_hidden) {
get_actor_registry()->inc_running();
......@@ -63,13 +63,12 @@ void scoped_actor::init(bool hidden) {
}
}
scoped_actor::scoped_actor() {
init(false);
}
scoped_actor::scoped_actor(bool hidden) {
init(hidden);
scoped_actor::scoped_actor(bool hide_actor) {
init(hide_actor);
}
scoped_actor::~scoped_actor() {
......
/******************************************************************************\
* ___ __ *
* /\_ \ __/\ \ *
* \//\ \ /\_\ \ \____ ___ _____ _____ __ *
* \ \ \ \/\ \ \ '__`\ /'___\/\ '__`\/\ '__`\ /'__`\ *
* \_\ \_\ \ \ \ \L\ \/\ \__/\ \ \L\ \ \ \L\ \/\ \L\.\_ *
* /\____\\ \_\ \_,__/\ \____\\ \ ,__/\ \ ,__/\ \__/.\_\ *
* \/____/ \/_/\/___/ \/____/ \ \ \/ \ \ \/ \/__/\/_/ *
* \ \_\ \ \_\ *
* \/_/ \/_/ *
* *
* Copyright (C) 2011-2013 *
* Dominik Charousset <dominik.charousset@haw-hamburg.de> *
* *
* This file is part of libcppa. *
* libcppa is free software: you can redistribute it and/or modify it under *
* the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, *
* or (at your option) any later version. *
* *
* libcppa is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with libcppa. If not, see <http://www.gnu.org/licenses/>. *
\******************************************************************************/
#include "cppa/io/stream.hpp"
namespace cppa {
namespace io {
stream::~stream() { }
} // namespace io
} // namespace cppa
......@@ -76,7 +76,7 @@ class string_serializer : public serializer {
ostream& out;
bool suppress_quotes;
pt_writer(ostream& mout, bool suppress_quotes = false) : out(mout), suppress_quotes(suppress_quotes) { }
pt_writer(ostream& mout, bool suppress = false) : out(mout), suppress_quotes(suppress) { }
template<typename T>
void operator()(const T& value) {
......@@ -222,7 +222,7 @@ class string_deserializer : public deserializer {
while (*m_pos == ' ' || *m_pos == ',') ++m_pos;
}
void throw_malformed(const string& error_msg) {
void throw_malformed [[noreturn]] (const string& error_msg) {
throw logic_error("malformed string: " + error_msg);
}
......
......@@ -376,7 +376,7 @@ inline void deserialize_impl(util::duration& val, deserializer* source) {
break;
default:
val.unit = util::time_unit::none;
val.unit = util::time_unit::invalid;
break;
}
val.count = count_val;
......@@ -810,7 +810,7 @@ class utim_impl : public uniform_type_info_map {
*i++ = &m_type_double; // double
*i++ = &m_type_float; // float
CPPA_REQUIRE(i == m_builtin_types.end());
# if CPPA_DEBUG_MODE
# ifdef CPPA_DEBUG_MODE
auto cmp = [](pointer lhs, pointer rhs) {
return strcmp(lhs->name(), rhs->name()) < 0;
};
......
......@@ -34,6 +34,8 @@
namespace cppa {
weak_ptr_anchor::~weak_ptr_anchor() { }
weak_ptr_anchor::weak_ptr_anchor(ref_counted* ptr) : m_ptr(ptr) { }
bool weak_ptr_anchor::try_expire() {
......
......@@ -16,7 +16,7 @@ void cppa_inc_error_count() {
++s_error_count;
}
string cppa_fill4(int value) {
string cppa_fill4(size_t value) {
string result = to_string(value);
while (result.size() < 4) result.insert(result.begin(), '0');
return result;
......
......@@ -26,7 +26,7 @@ void set_default_test_settings();
size_t cppa_error_count();
void cppa_inc_error_count();
std::string cppa_fill4(int value);
std::string cppa_fill4(size_t value);
const char* cppa_strip_path(const char* fname);
void cppa_unexpected_message(const char* fname, size_t line_num);
void cppa_unexpected_timeout(const char* fname, size_t line_num);
......@@ -75,7 +75,7 @@ inline std::string cppa_stream_arg(const bool& value) {
return value ? "true" : "false";
}
inline void cppa_passed(const char* fname, int line_number) {
inline void cppa_passed(const char* fname, size_t line_number) {
CPPA_PRINTC(fname, line_number, "passed");
}
......@@ -83,7 +83,7 @@ template<typename V1, typename V2>
inline void cppa_failed(const V1& v1,
const V2& v2,
const char* fname,
int line_number) {
size_t line_number) {
CPPA_PRINTERRC(fname, line_number,
"expected value: " << cppa_stream_arg(v2)
<< ", found: " << cppa_stream_arg(v1));
......@@ -93,7 +93,7 @@ inline void cppa_failed(const V1& v1,
inline void cppa_check_value(const std::string& v1,
const std::string& v2,
const char* fname,
int line,
size_t line,
bool expected = true) {
if ((v1 == v2) == expected) cppa_passed(fname, line);
else cppa_failed(v1, v2, fname, line);
......@@ -103,7 +103,7 @@ template<typename V1, typename V2>
inline void cppa_check_value(const V1& v1,
const V2& v2,
const char* fname,
int line,
size_t line,
bool expected = true,
typename enable_integral<false, V1, V2>::type* = 0) {
if ((v1 == v2) == expected) cppa_passed(fname, line);
......@@ -114,7 +114,7 @@ template<typename V1, typename V2>
inline void cppa_check_value(V1 v1,
V2 v2,
const char* fname,
int line,
size_t line,
bool expected = true,
typename enable_integral<true, V1, V2>::type* = 0) {
if ((v1 == static_cast<V1>(v2)) == expected) cppa_passed(fname, line);
......
......@@ -66,8 +66,8 @@ void pong(cppa::event_based_actor* self) {
self->monitor(self->last_sender());
// set next behavior
self->become (
on(atom("ping"), arg_match) >> [](int value) {
return make_cow_tuple(atom("pong"), value);
on(atom("ping"), arg_match) >> [](int val) {
return make_cow_tuple(atom("pong"), val);
},
on_arg_match >> [=](const down_msg& dm) {
self->quit(dm.reason);
......
#define CPPA_VERBOSE_CHECK
#include "cppa/config.hpp"
#include <new>
......@@ -138,14 +136,14 @@ struct raw_struct_type_info : util::abstract_uniform_type_info<raw_struct> {
};
void test_ieee_754() {
// check float packing
float f1 = 3.1415925; // float value
// check conversion of float
float f1 = 3.1415925f; // float value
auto p1 = cppa::detail::pack754(f1); // packet value
CPPA_CHECK_EQUAL(p1, 0x40490FDA);
auto u1 = cppa::detail::unpack754(p1); // unpacked value
CPPA_CHECK_EQUAL(f1, u1);
// check double packing
double f2 = 3.14159265358979311600; // float value
// check conversion of double
double f2 = 3.14159265358979311600; // double value
auto p2 = cppa::detail::pack754(f2); // packet value
CPPA_CHECK_EQUAL(p2, 0x400921FB54442D18);
auto u2 = cppa::detail::unpack754(p2); // unpacked value
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment