Skip to content

Commit 808602a

Browse files
authored
Merge pull request #74 from beman-project/set-up-codespaces
added container definitions and an example to play with
2 parents f3b66fc + d321114 commit 808602a

File tree

5 files changed

+64
-0
lines changed

5 files changed

+64
-0
lines changed

.devcontainer/Dockerfile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2+
3+
FROM mcr.microsoft.com/devcontainers/cpp:1-ubuntu-22.04
4+
5+
USER vscode
6+
7+
# Install latest cmake
8+
RUN wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | sudo tee /usr/share/keyrings/kitware-archive-keyring.gpg >/dev/null
9+
RUN echo 'deb [signed-by=/usr/share/keyrings/kitware-archive-keyring.gpg] https://apt.kitware.com/ubuntu/ jammy main' | sudo tee /etc/apt/sources.list.d/kitware.list >/dev/null
10+
RUN sudo apt-get update && sudo apt-get install -y cmake
11+
12+
# Install pre-commit
13+
RUN sudo apt-get install -y python3-pip && pip3 install pre-commit
14+
15+
# Avoid ASAN Stalling
16+
# Alternative is to update to clang-18 and gcc-13.2
17+
18+
RUN sudo sysctl -w vm.mmap_rnd_bits=28

.devcontainer/devcontainer.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
3+
// README at: https://github.com/devcontainers/templates/tree/main/src/cpp
4+
5+
{
6+
"name": "Beman Project Generic Devcontainer",
7+
"build": {
8+
"dockerfile": "Dockerfile"
9+
},
10+
"postCreateCommand": "bash .devcontainer/postcreate.sh",
11+
"customizations": {
12+
"vscode": {
13+
"extensions": [
14+
"ms-vscode.cpptools",
15+
"ms-vscode.cmake-tools"
16+
]
17+
}
18+
}
19+
}

.devcontainer/postcreate.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2+
# Setup pre-commit
3+
pre-commit
4+
pre-commit install

examples/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
list(
77
APPEND
88
EXAMPLES
9+
playground
910
sender-demo
1011
when_all-cancel
1112
stop_token

examples/playground.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// examples/playground.cpp -*-C++-*-
2+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3+
4+
#include <beman/execution26/execution.hpp>
5+
#include <iostream>
6+
#include <string>
7+
#include <tuple>
8+
9+
namespace ex = ::beman::execution26;
10+
11+
// ----------------------------------------------------------------------------
12+
13+
int main()
14+
{
15+
auto[result] = ex::sync_wait(
16+
ex::when_all(
17+
ex::just(std::string("hello, ")),
18+
ex::just(std::string("world"))
19+
) | ex::then([](auto s1, auto s2){ return s1 + s2; })
20+
).value_or(std::tuple(std::string("oops")));
21+
std::cout << "result='" << result << "'\n";
22+
}

0 commit comments

Comments
 (0)