Skip to content

Commit

Permalink
add experimental supervisor
Browse files Browse the repository at this point in the history
  • Loading branch information
kotbegemot authored Sep 14, 2019
1 parent 9dcbee9 commit ff7c733
Show file tree
Hide file tree
Showing 77 changed files with 1,474 additions and 1,335 deletions.
13 changes: 12 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ matrix:
##########################################################################
# Clang on OSX
##########################################################################

# XCode 7.3
- os: osx
osx_image: xcode7.3
Expand Down Expand Up @@ -65,6 +64,18 @@ matrix:
# GCC on Linux
##########################################################################

# GCC 4.8
- env: COMPILER=g++-4.8 BUILD_TYPE=Debug
addons: &gcc48
apt:
packages:
- g++-4.8
sources:
- ubuntu-toolchain-r-test

- env: COMPILER=g++-4.8 BUILD_TYPE=Release
addons: *gcc48

# GCC 4.9
- env: COMPILER=g++-4.9 BUILD_TYPE=Debug
addons: &gcc49
Expand Down
12 changes: 6 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ message (STATUS "CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")

option(CMake_RUN_CLANG_TIDY "Run clang-tidy with the compiler." OFF)

option(IO "Enable building actor-zeta-io" ON)
option(ENV "Enable building actor-zeta-environment" ON)

option(ALLOW_EXAMPLES "Enable building examples" OFF)

Expand Down Expand Up @@ -121,10 +121,10 @@ include_directories(core)
add_subdirectory(core)
list(APPEND OBJECT_LISTS "$<TARGET_OBJECTS:actor-zeta-core>")

if(IO)
include_directories(io)
add_subdirectory(io)
list(APPEND OBJECT_LISTS "$<TARGET_OBJECTS:actor-zeta-io>")
if(ENV)
include_directories(environment)
add_subdirectory(environment)
list(APPEND OBJECT_LISTS "$<TARGET_OBJECTS:actor-zeta-environment>")
endif()

find_package( Threads )
Expand All @@ -142,7 +142,7 @@ target_include_directories(
${PROJECT_NAME}
PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/core/actor-zeta
${CMAKE_CURRENT_SOURCE_DIR}/io/actor-zeta
${CMAKE_CURRENT_SOURCE_DIR}/environment/actor-zeta
)

if(ALLOW_EXAMPLES)
Expand Down
46 changes: 41 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,63 @@
[![Build Status](https://travis-ci.org/smart-cloud/actor-zeta.svg?branch=master)](https://travis-ci.org/smart-cloud/actor-zeta)
[![Build Status](https://travis-ci.org/jinntechio/actor-zeta.svg?branch=master)](https://travis-ci.org/jinntechio/actor-zeta)

actor-zeta
========================

actor-zeta is an open source C++11 virtual actor model implementation featuring lightweight & fast and more.

The libraray uses a standard practice for its versioning: major.minor.patchlevel. example : 0.0.1
### Example

This project is in a very early / experimental stage.
```C++

#include <actor-zeta/core.hpp>

using actor_zeta::context;
using actor_zeta::basic_async_actor;


class storage_t final : public basic_async_actor {
public:
storage_t() : basic_async_actor(nullptr, "storage") {
add_handler(
"update",
[](context & /*ctx*/, query_t& query) -> void {

}
);

add_handler(
"find",
[](context & /*ctx*/, query_t& query) -> void {
}
);

add_handler(
"remove",
[](context & /*ctx*/, query_t& query) -> void {
}
);
}

~storage_t() override = default;
};

```
## Dependencies
* CMake
## Supported Compilers
* GCC >= 4.8
* GCC >= 4.8.5
* Clang >= 3.3
* Microsoft Visual Studio >= 2015
## Supported Operating Systems
* Linux
* Mac OS X
* Windows
* FreeBSD 10
* Windows >= 7 (static builds)
43 changes: 11 additions & 32 deletions core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,22 @@ else()
PROJECT(${project} VERSION "${CMAKE_PROJECT_VERSION}" LANGUAGES CXX)
endif()

include_directories(.)
include_directories(SYSTEM .)

set(HEADER_FILES
actor-zeta/actor/handler.hpp
actor-zeta/actor/abstract_actor.hpp
actor-zeta/actor/actor.hpp
actor-zeta/actor/actor_address.hpp
actor-zeta/actor/async_actor.hpp
actor-zeta/actor/cooperative_actor.hpp
actor-zeta/actor/base_actor.hpp
actor-zeta/actor/basic_actor.hpp
actor-zeta/actor/blocking_actor.hpp
actor-zeta/actor/context.hpp
actor-zeta/actor/local_actor.hpp
actor-zeta/actor/dispatcher.hpp
actor-zeta/actor/handler.hpp
actor-zeta/actor/metadata.hpp
actor-zeta/actor/supervisor.hpp

actor-zeta/channel/abstract_channel.hpp
actor-zeta/channel/channel.hpp

actor-zeta/detail/adjacency_list.hpp
actor-zeta/detail/any.hpp
actor-zeta/detail/callable_trait.hpp
actor-zeta/detail/intrusive_ptr.hpp
Expand All @@ -35,13 +33,6 @@ set(HEADER_FILES
actor-zeta/detail/type_list.hpp
actor-zeta/detail/type_traits.hpp

actor-zeta/environment/abstract_environment.hpp
actor-zeta/environment/abstract_group.hpp
actor-zeta/environment/cooperation.hpp
actor-zeta/environment/environment.hpp
actor-zeta/environment/group.hpp
actor-zeta/environment/storage_space.hpp

actor-zeta/executor/policy/profiled.hpp
actor-zeta/executor/policy/unprofiled.hpp
actor-zeta/executor/policy/work_sharing.hpp
Expand All @@ -58,32 +49,21 @@ set(HEADER_FILES
actor-zeta/messaging/message_header.hpp

actor-zeta/forwards.hpp
actor-zeta/metadata.hpp
)

set(SOURCE_FILES

source/actor/abstract_actor.cpp
source/actor/actor.cpp
source/actor/actor_address.cpp
source/actor/async_actor.cpp
source/actor/cooperative_actor.cpp
source/actor/blocking_actor.cpp
source/actor/context.cpp
source/actor/local_actor.cpp
source/actor/dispatcher.cpp
source/actor/supervisor.cpp

source/detail/string_view.cpp

source/channel/abstract_channel.cpp
source/channel/channel.cpp

source/environment/abstract_environment.cpp
source/environment/storage_space.cpp
source/environment/abstract_group.cpp
source/environment/cooperation.cpp
source/environment/environment.cpp
source/environment/group.cpp
source/environment/storage_space.cpp
source/detail/ref_counted.cpp

source/executor/abstract_executor.cpp
source/executor/executable.cpp
Expand All @@ -92,9 +72,8 @@ set(SOURCE_FILES
source/messaging/message.cpp
source/messaging/message_header.cpp
source/messaging/blocking_mail_queue.cpp

source/ref_counted.cpp
)
source/actor/base_actor.cpp
source/actor/executable_actor.cpp)

add_library(
${PROJECT_NAME} OBJECT
Expand Down
32 changes: 13 additions & 19 deletions core/actor-zeta/actor/abstract_actor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

#include <set>

#include <actor-zeta/channel/abstract_channel.hpp>
#include <actor-zeta/environment/environment.hpp>
#include <actor-zeta/detail/ref_counted.hpp>
#include <actor-zeta/actor/metadata.hpp>
#include <actor-zeta/forwards.hpp>
#include <actor-zeta/detail/string_view.hpp>

namespace actor_zeta { namespace actor {
///
Expand All @@ -13,37 +14,30 @@ namespace actor_zeta { namespace actor {

class abstract_actor : public ref_counted {
public:
abstract_actor() = delete;
abstract_actor()= delete;

abstract_actor(const abstract_actor &) = delete;

abstract_actor &operator=(const abstract_actor &) = delete;

~abstract_actor() override;

virtual bool send(messaging::message) = 0;
explicit abstract_actor(detail::string_view);

virtual bool send(messaging::message, executor::execution_device *) = 0;
auto enqueue(messaging::message) -> void;

actor_address address() const noexcept;
virtual void enqueue(messaging::message, executor::execution_device *) = 0;

auto type() const -> abstract;
virtual auto message_types() const -> std::set<std::string> ;

auto name() const -> const std::string &;
actor_address address() const noexcept;

auto locating() const -> locations;
auto type() const -> abstract;

virtual auto message_types() const -> std::set<std::string> ;
auto name() const -> detail::string_view;

protected:
auto env() -> environment::environment& ;

abstract_actor(environment::abstract_environment *, const std::string &);

metadata type_;

private:
environment::environment env_;
};
}
}

}}
8 changes: 4 additions & 4 deletions core/actor-zeta/actor/actor.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#pragma once

#include <string>

#include <actor-zeta/detail/string_view.hpp>
#include <actor-zeta/detail/intrusive_ptr.hpp>
#include <actor-zeta/forwards.hpp>

Expand Down Expand Up @@ -53,7 +55,7 @@ namespace actor_zeta { namespace actor {
return static_cast<bool>(ptr_);
}

const std::string &name() const;
auto name() const -> detail::string_view;

inline bool operator!() const noexcept {
return !ptr_;
Expand All @@ -65,6 +67,4 @@ namespace actor_zeta { namespace actor {

intrusive_ptr <abstract_actor> ptr_;
};
}

}
}}
59 changes: 59 additions & 0 deletions core/actor-zeta/actor/base_actor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#pragma once

#include <memory>
#include <unordered_map>

#include <actor-zeta/forwards.hpp>
#include <actor-zeta/actor/abstract_actor.hpp>
#include <actor-zeta/actor/context.hpp>
#include <actor-zeta/actor/dispatcher.hpp>

namespace actor_zeta { namespace actor {
///
/// @brief A generic actor
///
class base_actor
: public abstract_actor
, public context_t {
public:
~base_actor() override;
protected:
/**
* debug method
*/
auto all_view_address() const -> void;

base_actor(detail::string_view name);

/// sync -> async
void add_link(actor_address);
/// sync -> async
void remove_link(const actor_address&);
/// sync -> async
void remove_link(detail::string_view);

auto message_types() const -> std::set<std::string> final;

auto addresses(detail::string_view) -> actor_address & final;

auto self() -> actor_address override;

template<std::size_t N, typename F>
inline auto add_handler(const char(&name)[N], F &&f) -> void {
dispatch().on(detail::string_view(name), make_handler(std::forward<F>(f)));
}

auto dispatch() -> dispatcher_t &;

auto dispatch() const -> const dispatcher_t &;

std::unordered_map<detail::string_view, actor_address> contacts;

private:
void initialize();

dispatcher_t dispatcher_;

};

}}
Loading

0 comments on commit ff7c733

Please sign in to comment.