Commit 9c00c1ae authored by Dominik Charousset's avatar Dominik Charousset

documentation update

parent 6e74c7fd
...@@ -565,7 +565,7 @@ WARN_LOGFILE = ...@@ -565,7 +565,7 @@ WARN_LOGFILE =
# directories like "/usr/src/myproject". Separate the files or directories # directories like "/usr/src/myproject". Separate the files or directories
# with spaces. # with spaces.
INPUT = @CMAKE_HOME_DIRECTORY@/cppa/ @CMAKE_HOME_DIRECTORY@/cppa/util @CMAKE_HOME_DIRECTORY@/cppa/intrusive INPUT = @CMAKE_HOME_DIRECTORY@/cppa/ @CMAKE_HOME_DIRECTORY@/cppa/util @CMAKE_HOME_DIRECTORY@/cppa/intrusive @CMAKE_HOME_DIRECTORY@/cppa/network
# This tag can be used to specify the character encoding of the source files # This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
......
...@@ -137,6 +137,9 @@ ...@@ -137,6 +137,9 @@
* @namespace cppa::intrusive * @namespace cppa::intrusive
* @brief Contains intrusive container implementations. * @brief Contains intrusive container implementations.
* *
* @namespace cppa::network
* @brief Contains all network related classes.
*
* @namespace cppa::factory * @namespace cppa::factory
* @brief Contains factory functions to create actors from lambdas or * @brief Contains factory functions to create actors from lambdas or
* other functors. * other functors.
......
...@@ -44,20 +44,20 @@ ...@@ -44,20 +44,20 @@
namespace cppa { namespace cppa {
/**
* @brief Enables derived classes to be used in {@link weak_intrusive_ptr}.
*/
template<class Base> template<class Base>
class enable_weak_ptr_mixin : public Base { class enable_weak_ptr_mixin : public Base {
typedef Base super; typedef Base super;
template<typename T>
friend class weak_intrusive_ptr;
static_assert(std::is_base_of<ref_counted,Base>::value, static_assert(std::is_base_of<ref_counted,Base>::value,
"Base needs to be derived from ref_counted"); "Base needs to be derived from ref_counted");
public:
inline intrusive_ptr<weak_ptr_anchor> get_weak_ptr_anchor() const {
return m_anchor;
}
protected: protected:
template<typename... Args> template<typename... Args>
...@@ -71,6 +71,10 @@ class enable_weak_ptr_mixin : public Base { ...@@ -71,6 +71,10 @@ class enable_weak_ptr_mixin : public Base {
private: private:
inline intrusive_ptr<weak_ptr_anchor> get_weak_ptr_anchor() const {
return m_anchor;
}
intrusive_ptr<weak_ptr_anchor> m_anchor; intrusive_ptr<weak_ptr_anchor> m_anchor;
}; };
......
...@@ -41,6 +41,10 @@ ...@@ -41,6 +41,10 @@
namespace cppa { namespace network { namespace cppa { namespace network {
/**
* @brief Encapsulates a message along with sender and receiver information
* as well as its synchronous message id.
*/
class addressed_message { class addressed_message {
public: public:
...@@ -99,8 +103,14 @@ class addressed_message { ...@@ -99,8 +103,14 @@ class addressed_message {
}; };
/**
* @relates addressed_message
*/
bool operator==(const addressed_message& lhs, const addressed_message& rhs); bool operator==(const addressed_message& lhs, const addressed_message& rhs);
/**
* @relates addressed_message
*/
inline bool operator!=(const addressed_message& lhs, inline bool operator!=(const addressed_message& lhs,
const addressed_message& rhs) { const addressed_message& rhs) {
return !(lhs == rhs); return !(lhs == rhs);
......
...@@ -42,6 +42,10 @@ namespace cppa { namespace network { ...@@ -42,6 +42,10 @@ namespace cppa { namespace network {
class middleman; class middleman;
/**
* @brief Denotes the return value of
* {@link continuable_reader::continue_reading()}.
*/
enum continue_reading_result { enum continue_reading_result {
read_failure, read_failure,
read_closed, read_closed,
...@@ -50,6 +54,9 @@ enum continue_reading_result { ...@@ -50,6 +54,9 @@ enum continue_reading_result {
class continuable_writer; class continuable_writer;
/**
* @brief An object performing asynchronous input on a file handle.
*/
class continuable_reader : virtual public ref_counted { class continuable_reader : virtual public ref_counted {
public: public:
...@@ -65,7 +72,8 @@ class continuable_reader : virtual public ref_counted { ...@@ -65,7 +72,8 @@ class continuable_reader : virtual public ref_counted {
virtual continue_reading_result continue_reading() = 0; virtual continue_reading_result continue_reading() = 0;
/** /**
* @return Casts @p this to a continuable_writer or returns @p nullptr. * @return Casts @p this to a continuable_writer, returns @p nullptr
* if cast fails.
*/ */
virtual continuable_writer* as_writer(); virtual continuable_writer* as_writer();
......
...@@ -37,6 +37,10 @@ ...@@ -37,6 +37,10 @@
namespace cppa { namespace network { namespace cppa { namespace network {
/**
* @brief Denotes the return value of
* {@link continuable_writer::continue_writing()}.
*/
enum continue_writing_result { enum continue_writing_result {
write_failure, write_failure,
write_closed, write_closed,
...@@ -44,6 +48,9 @@ enum continue_writing_result { ...@@ -44,6 +48,9 @@ enum continue_writing_result {
write_done write_done
}; };
/**
* @brief An object performing asynchronous output on a file handle.
*/
class continuable_writer : virtual public ref_counted { class continuable_writer : virtual public ref_counted {
typedef ref_counted super; typedef ref_counted super;
......
...@@ -45,6 +45,9 @@ namespace cppa { namespace detail { class singleton_manager; } } ...@@ -45,6 +45,9 @@ namespace cppa { namespace detail { class singleton_manager; } }
namespace cppa { namespace network { namespace cppa { namespace network {
/**
* @brief Multiplexes asynchronous IO.
*/
class middleman { class middleman {
friend class detail::singleton_manager; friend class detail::singleton_manager;
...@@ -53,11 +56,19 @@ class middleman { ...@@ -53,11 +56,19 @@ class middleman {
virtual ~middleman(); virtual ~middleman();
/**
* @brief Add a new communication protocol to the middleman.
*/
virtual void add_protocol(const protocol_ptr& impl) = 0; virtual void add_protocol(const protocol_ptr& impl) = 0;
/**
* @brief Returns the protocol associated with @p id.
*/
virtual protocol_ptr protocol(atom_value id) = 0; virtual protocol_ptr protocol(atom_value id) = 0;
// runs @p fun in the middleman's event loop /**
* @brief Runs @p fun in the middleman's event loop.
*/
virtual void run_later(std::function<void()> fun) = 0; virtual void run_later(std::function<void()> fun) = 0;
protected: protected:
......
...@@ -45,16 +45,19 @@ namespace cppa { namespace network { ...@@ -45,16 +45,19 @@ namespace cppa { namespace network {
typedef int event_bitmask; typedef int event_bitmask;
namespace event { namespace event { namespace {
static constexpr event_bitmask none = 0x00; constexpr event_bitmask none = 0x00;
static constexpr event_bitmask read = 0x01; constexpr event_bitmask read = 0x01;
static constexpr event_bitmask write = 0x02; constexpr event_bitmask write = 0x02;
static constexpr event_bitmask both = 0x03; constexpr event_bitmask both = 0x03;
static constexpr event_bitmask error = 0x04; constexpr event_bitmask error = 0x04;
} // namespace event } } // namespace event
/**
* @brief Converts an event bitmask to a human-readable string.
*/
inline const char* eb2str(event_bitmask e) { inline const char* eb2str(event_bitmask e) {
switch (e) { switch (e) {
default: return "INVALID"; default: return "INVALID";
......
...@@ -50,6 +50,9 @@ class abstract_middleman; ...@@ -50,6 +50,9 @@ class abstract_middleman;
class continuable_reader; class continuable_reader;
class continuable_writer; class continuable_writer;
/**
* @brief Implements a communication protocol.
*/
class protocol : public ref_counted { class protocol : public ref_counted {
typedef ref_counted super; typedef ref_counted super;
......
...@@ -40,6 +40,9 @@ ...@@ -40,6 +40,9 @@
namespace cppa { namespace cppa {
/**
* @brief A smart pointer that does not increase the reference count.
*/
template<typename T> template<typename T>
class weak_intrusive_ptr : util::comparable<weak_intrusive_ptr<T>> { class weak_intrusive_ptr : util::comparable<weak_intrusive_ptr<T>> {
...@@ -55,7 +58,7 @@ class weak_intrusive_ptr : util::comparable<weak_intrusive_ptr<T>> { ...@@ -55,7 +58,7 @@ class weak_intrusive_ptr : util::comparable<weak_intrusive_ptr<T>> {
/** /**
* @brief Promotes this weak pointer to an intrusive_ptr. * @brief Promotes this weak pointer to an intrusive_ptr.
* @warning Returns @p nullptr if expired. * @warning Returns @p nullptr if {@link expired()}.
*/ */
intrusive_ptr<T> promote() { intrusive_ptr<T> promote() {
return (m_anchor) ? m_anchor->get<T>() : nullptr; return (m_anchor) ? m_anchor->get<T>() : nullptr;
...@@ -74,7 +77,7 @@ class weak_intrusive_ptr : util::comparable<weak_intrusive_ptr<T>> { ...@@ -74,7 +77,7 @@ class weak_intrusive_ptr : util::comparable<weak_intrusive_ptr<T>> {
/** /**
* @brief Queries whether this weak pointer is invalid, i.e., does not * @brief Queries whether this weak pointer is invalid, i.e., does not
* point to an instance. * point to an object.
*/ */
inline bool invalid() const { inline bool invalid() const {
return m_anchor == nullptr; return m_anchor == nullptr;
......
...@@ -39,12 +39,19 @@ ...@@ -39,12 +39,19 @@
namespace cppa { namespace cppa {
/**
* @brief A storage holding a spinlock and a pointer to a
* reference counted object.
*/
class weak_ptr_anchor : public ref_counted { class weak_ptr_anchor : public ref_counted {
public: public:
weak_ptr_anchor(ref_counted* ptr); weak_ptr_anchor(ref_counted* ptr);
/**
* @brief Gets a pointer to the object or nullptr if {@link expired()}.
*/
template<typename T> template<typename T>
intrusive_ptr<T> get() { intrusive_ptr<T> get() {
intrusive_ptr<T> result; intrusive_ptr<T> result;
...@@ -55,11 +62,18 @@ class weak_ptr_anchor : public ref_counted { ...@@ -55,11 +62,18 @@ class weak_ptr_anchor : public ref_counted {
return result; return result;
} }
/**
* @brief Queries whether the object was already deleted.
*/
inline bool expired() const { inline bool expired() const {
// no need for locking since pointer comparison is atomic // no need for locking since pointer comparison is atomic
return m_ptr == nullptr; return m_ptr == nullptr;
} }
/**
* @brief Tries to expire this anchor. Fails if reference count of object
* is not zero.
*/
bool try_expire(); bool try_expire();
private: private:
......
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