Skip to content

Commit 9b987d4

Browse files
author
birydrad
committed
coroutines support in actors
1 parent 7810271 commit 9b987d4

37 files changed

+4206
-164
lines changed

CMakeLists.txt

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ option(TONLIB_ENABLE_JNI "Use \"ON\" to enable JNI-compatible TonLib API.")
5656
option(TON_USE_ASAN "Use \"ON\" to enable AddressSanitizer." OFF)
5757
option(TON_USE_TSAN "Use \"ON\" to enable ThreadSanitizer." OFF)
5858
option(TON_USE_UBSAN "Use \"ON\" to enable UndefinedBehaviorSanitizer." OFF)
59+
option(TON_USE_COVERAGE "Use \"ON\" to enable code coverage with gcov." OFF)
5960
set(TON_ARCH "native" CACHE STRING "Architecture, will be passed to -march=")
6061

6162
option(TON_PRINT_BACKTRACE_ON_CRASH "Attempt to print a backtrace when a fatal signal is caught" ON)
@@ -251,7 +252,7 @@ elseif (CLANG OR GCC)
251252
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections -Wl,--exclude-libs,ALL")
252253
endif()
253254
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
254-
if (NOT TON_USE_ASAN AND NOT TON_USE_TSAN AND NOT MEMPROF)
255+
if (NOT TON_USE_ASAN AND NOT TON_USE_TSAN AND NOT TON_USE_COVERAGE AND NOT MEMPROF)
255256
if (NOT USE_EMSCRIPTEN)
256257
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--exclude-libs,ALL")
257258
endif()
@@ -337,6 +338,18 @@ endif()
337338
if (TON_USE_UBSAN)
338339
add_cxx_compiler_flag("-fsanitize=undefined")
339340
endif()
341+
if (TON_USE_COVERAGE)
342+
add_cxx_compiler_flag("-fprofile-arcs")
343+
add_cxx_compiler_flag("-ftest-coverage")
344+
add_cxx_compiler_flag("--coverage")
345+
add_cxx_compiler_flag("-O0")
346+
add_cxx_compiler_flag("-g")
347+
add_cxx_compiler_flag("-fno-inline")
348+
add_cxx_compiler_flag("-fno-inline-small-functions")
349+
add_cxx_compiler_flag("-fno-default-inline")
350+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage --coverage")
351+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage --coverage")
352+
endif()
340353
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
341354
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
342355
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
@@ -554,6 +567,7 @@ add_test(test-cells test-cells ${TEST_OPTIONS})
554567
add_test(test-smartcont test-smartcont)
555568
add_test(test-net test-net)
556569
add_test(test-actors test-tdactor)
570+
add_test(test-actors-coro tdactor/test/test-coro)
557571
add_test(test-emulator test-emulator)
558572

559573
#BEGIN tonlib

assembly/native/build-macos-portable.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ if [ "$with_tests" = true ]; then
153153
lite-client validator-engine-console generate-random-id json2tlo dht-server dht-ping-servers dht-resolve \
154154
http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork tlbc emulator \
155155
test-ed25519 test-bigint test-vm test-fift test-cells test-smartcont \
156-
test-net test-tdactor test-tdutils test-tonlib-offline test-adnl test-dht test-rldp \
156+
test-net test-tdactor test-coro test-tdutils test-tonlib-offline test-adnl test-dht test-rldp \
157157
test-rldp2 test-catchain test-fec test-tddb test-db test-validator-session-state test-emulator proxy-liteserver
158158
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
159159
else

assembly/native/build-macos-shared.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ if [ "$with_tests" = true ]; then
9191
lite-client validator-engine-console generate-random-id json2tlo dht-server dht-ping-servers dht-resolve \
9292
http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork tlbc emulator \
9393
test-ed25519 test-bigint test-vm test-fift test-cells test-smartcont \
94-
test-net test-tdactor test-tdutils test-tonlib-offline test-adnl test-dht test-rldp \
94+
test-net test-tdactor test-coro test-tdutils test-tonlib-offline test-adnl test-dht test-rldp \
9595
test-rldp2 test-catchain test-fec test-tddb test-db test-validator-session-state test-emulator proxy-liteserver
9696
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }
9797
else

assembly/native/build-ubuntu-appimages.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ ninja storage-daemon storage-daemon-cli fift func tolk tonlib tonlibjson tonlib-
6363
validator-engine lite-client validator-engine-console blockchain-explorer \
6464
generate-random-id json2tlo dht-server http-proxy rldp-http-proxy dht-ping-servers dht-resolve \
6565
adnl-proxy create-state emulator test-ed25519 test-bigint \
66-
test-vm test-fift test-cells test-smartcont test-net test-tdactor test-tdutils \
66+
test-vm test-fift test-cells test-smartcont test-net test-tdactor test-coro test-tdutils \
6767
test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain \
6868
test-fec test-tddb test-db test-validator-session-state test-emulator proxy-liteserver
6969
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }

assembly/native/build-ubuntu-portable.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ ninja storage-daemon storage-daemon-cli fift func tolk tonlib tonlibjson tonlib-
137137
validator-engine lite-client validator-engine-console blockchain-explorer \
138138
generate-random-id json2tlo dht-server http-proxy rldp-http-proxy dht-ping-servers dht-resolve \
139139
adnl-proxy create-state emulator test-ed25519 test-bigint \
140-
test-vm test-fift test-cells test-smartcont test-net test-tdactor test-tdutils \
140+
test-vm test-fift test-cells test-smartcont test-net test-tdactor test-coro test-tdutils \
141141
test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain \
142142
test-fec test-tddb test-db test-validator-session-state test-emulator proxy-liteserver
143143
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }

assembly/native/build-ubuntu-shared.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ ninja storage-daemon storage-daemon-cli fift func tolk tonlib tonlibjson tonlib-
6666
validator-engine lite-client validator-engine-console blockchain-explorer \
6767
generate-random-id json2tlo dht-server http-proxy rldp-http-proxy dht-ping-servers dht-resolve \
6868
adnl-proxy create-state emulator test-ed25519 test-bigint \
69-
test-vm test-fift test-cells test-smartcont test-net test-tdactor test-tdutils \
69+
test-vm test-fift test-cells test-smartcont test-net test-tdactor test-coro test-tdutils \
7070
test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain \
7171
test-fec test-tddb test-db test-validator-session-state test-emulator proxy-liteserver
7272
test $? -eq 0 || { echo "Can't compile ton"; exit 1; }

assembly/native/build-windows-2019.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ ninja storage-daemon storage-daemon-cli blockchain-explorer fift func tolk tonli
148148
tonlib-cli validator-engine lite-client validator-engine-console generate-random-id ^
149149
json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork emulator ^
150150
test-ed25519 test-bigint test-vm test-fift test-cells test-smartcont test-net ^
151-
test-tdactor test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain ^
151+
test-tdactor test-coro test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain ^
152152
test-fec test-tddb test-db test-validator-session-state test-emulator proxy-liteserver dht-ping-servers dht-resolve
153153
IF %errorlevel% NEQ 0 (
154154
echo Can't compile TON

assembly/native/build-windows-2022.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ ninja storage-daemon storage-daemon-cli blockchain-explorer fift func tolk tonli
148148
tonlib-cli validator-engine lite-client validator-engine-console generate-random-id ^
149149
json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork emulator ^
150150
test-ed25519 test-bigint test-vm test-fift test-cells test-smartcont test-net ^
151-
test-tdactor test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain ^
151+
test-tdactor test-coro test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain ^
152152
test-fec test-tddb test-db test-validator-session-state test-emulator proxy-liteserver
153153
IF %errorlevel% NEQ 0 (
154154
echo Can't compile TON

assembly/native/build-windows.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ ninja storage-daemon storage-daemon-cli blockchain-explorer fift func tolk tonli
148148
tonlib-cli validator-engine lite-client validator-engine-console generate-random-id ^
149149
json2tlo dht-server http-proxy rldp-http-proxy adnl-proxy create-state create-hardfork emulator ^
150150
test-ed25519 test-bigint test-vm test-fift test-cells test-smartcont test-net ^
151-
test-tdactor test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain ^
151+
test-tdactor test-coro test-tdutils test-tonlib-offline test-adnl test-dht test-rldp test-rldp2 test-catchain ^
152152
test-fec test-tddb test-db test-validator-session-state test-emulator proxy-liteserver dht-ping-servers dht-resolve
153153
IF %errorlevel% NEQ 0 (
154154
echo Can't compile TON

tdactor/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ set(TDACTOR_SOURCE
1515
td/actor/ActorShared.h
1616
td/actor/ActorStats.h
1717
td/actor/common.h
18+
td/actor/coro.h
1819
td/actor/PromiseFuture.h
1920
td/actor/MultiPromise.h
2021

@@ -52,8 +53,12 @@ add_library(tdactor STATIC ${TDACTOR_SOURCE})
5253
target_include_directories(tdactor PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
5354
target_link_libraries(tdactor PUBLIC tdutils)
5455

56+
add_executable(tdactor-example-coroutines example/actor-example-coroutines.cpp)
57+
target_link_libraries(tdactor-example-coroutines PUBLIC tdactor)
58+
5559
# BEGIN-INTERNAL
5660
add_subdirectory(benchmark)
61+
add_subdirectory(test)
5762

5863
# END-INTERNAL
5964
install(TARGETS tdactor EXPORT TdTargets

0 commit comments

Comments
 (0)