Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
ca-certificates \
curl \
gnupg2 \
libssl-dev \
vim \
software-properties-common \
graphviz xdot \
ninja-build \
&& add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
Expand All @@ -33,6 +35,15 @@ RUN curl -L -O https://github.com/bazelbuild/buildtools/releases/download/3.5.0/
&& chmod +x buildifier \
&& mv buildifier /usr/local/bin

RUN curl -L -O https://github.com/actor-framework/actor-framework/archive/c2be26e7f9e3e84ef14730590fc4e7b25fb9d29a.zip \
&& unzip -d caf c2be26e7f9e3e84ef14730590fc4e7b25fb9d29a.zip \
&& cd caf/actor-framework-c2be26e7f9e3e84ef14730590fc4e7b25fb9d29a/ \
&& ./configure --generator=Ninja \
&& cd build \
&& cmake -G "Ninja" .. \
&& ninja install \
&& cd ../../.. \
&& rm -rf caf

RUN locale-gen en_US.UTF-8
ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8'
Expand Down
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
// "postCreateCommand": "gcc -v",

// Comment out this line to run as root instead.
"remoteUser": "vscode"
"remoteUser": "vscode",

}
11 changes: 10 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository", "new_git_repository")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

git_repository(
name = "googletest",
Expand All @@ -15,6 +16,14 @@ new_local_repository(
new_git_repository(
name = "fmt",
remote = "https://github.com/fmtlib/fmt",
branch = "master",
commit = "6884aab49b1b7fc6dcba1e27999f1aced0b888be",
shallow_since = "1641501513 -0800",
build_file = "//:fmt.BUILD",
)

new_local_repository(
name = "caf",
path = "/usr/local",
build_file = "caf.BUILD",

)
15 changes: 15 additions & 0 deletions actor/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
load("@rules_cc//cc:defs.bzl", "cc_binary")
load("@//:global_copts.bzl", "global_copts")

package(features = ["-default_compile_flags"])

cc_binary(
name = "actor",
srcs = ["actor.cpp"],
copts = global_copts(),
deps = [
"@caf//:main",
"@fmt//:main",
"@ncurses//:main",
],
)
45 changes: 45 additions & 0 deletions actor/actor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#include <string>
#include <iostream>

#include "caf/actor_ostream.hpp"
#include "caf/actor_system.hpp"
#include "caf/caf_main.hpp"
#include "caf/event_based_actor.hpp"

using namespace caf;

behavior mirror(event_based_actor* self) {
// return the (initial) actor behavior
return {
// a handler for messages containing a single string
// that replies with a string
[=](const std::string& what) -> std::string {
// prints "Hello World!" via aout (thread-safe cout wrapper)
aout(self) << what << std::endl;
// reply "!dlroW olleH"
return std::string{what.rbegin(), what.rend()};
},
};
}

void hello_world(event_based_actor* self, const actor& buddy) {
// send "Hello World!" to our buddy ...
self->request(buddy, std::chrono::seconds(10), "Hello World!")
.then(
// ... wait up to 10s for a response ...
[=](const std::string& what) {
// ... and print it
aout(self) << what << std::endl;
});
}

void caf_main(actor_system& sys) {
// create a new actor that calls 'mirror()'
auto mirror_actor = sys.spawn(mirror);
// create another actor that calls 'hello_world(mirror_actor)';
sys.spawn(hello_world, mirror_actor);
// the system will wait until both actors are done before exiting the program
}

// creates a main function for us that calls our caf_main
CAF_MAIN()
14 changes: 14 additions & 0 deletions caf.BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("@rules_cc//cc:defs.bzl", "cc_library")

cc_library(
name = "main",
srcs = [
"lib/libcaf_openssl.so.0.18.5",
"lib/libcaf_io.so",
"lib/libcaf_openssl.so",
"lib/libcaf_io.so.0.18.5",
"lib/libcaf_core.so.0.18.5",
"lib/libcaf_core.so",
],
visibility = ["//visibility:public"],
)
10 changes: 10 additions & 0 deletions util/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,13 @@ cc_binary(
"@ncurses//:main",
],
)

cc_binary(
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore

name = "scratch",
srcs = ["scratch.cpp"],
copts = global_copts(),
deps = [
"@fmt//:main",
"@ncurses//:main",
],
)
15 changes: 15 additions & 0 deletions util/scratch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#include "include/fmt/format.h"
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore

#include "include/fmt/printf.h"

#include <memory>

int main(int /*argc*/, char** /*argv*/) {

std::unique_ptr<int> pint = std::make_unique<int>();
std::shared_ptr<int> spint = std::move(pint);
*spint = 10;

fmt::printf("Value is %d\n", *spint);

return 0;
}