Skip to content

Commit a0314f0

Browse files
authored
Merge pull request #1791 from birydrad/testnet
coroutines support in actors
2 parents 4df3609 + 8430c54 commit a0314f0

37 files changed

+4211
-164
lines changed

CMakeLists.txt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ option(TONLIB_ENABLE_JNI "Use \"ON\" to enable JNI-compatible TonLib API.")
6565
option(TON_USE_ASAN "Use \"ON\" to enable AddressSanitizer." OFF)
6666
option(TON_USE_TSAN "Use \"ON\" to enable ThreadSanitizer." OFF)
6767
option(TON_USE_UBSAN "Use \"ON\" to enable UndefinedBehaviorSanitizer." OFF)
68+
option(TON_USE_COVERAGE "Use \"ON\" to enable code coverage with gcov." OFF)
6869
set(TON_ARCH "native" CACHE STRING "Architecture, will be passed to -march=")
6970

7071
option(TON_PRINT_BACKTRACE_ON_CRASH "Attempt to print a backtrace when a fatal signal is caught" ON)
@@ -266,7 +267,7 @@ elseif (CLANG OR GCC)
266267
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections -Wl,--exclude-libs,ALL")
267268
endif()
268269
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
269-
if (NOT TON_USE_ASAN AND NOT TON_USE_TSAN AND NOT MEMPROF)
270+
if (NOT TON_USE_ASAN AND NOT TON_USE_TSAN AND NOT TON_USE_COVERAGE AND NOT MEMPROF)
270271
if (NOT USE_EMSCRIPTEN)
271272
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--exclude-libs,ALL")
272273
endif()
@@ -350,6 +351,23 @@ if (TON_USE_UBSAN)
350351
add_compile_options(-fsanitize=undefined)
351352
add_link_options(-fsanitize=undefined)
352353
endif()
354+
if (TON_USE_COVERAGE)
355+
add_cxx_compiler_flag("-fprofile-arcs")
356+
add_cxx_compiler_flag("-ftest-coverage")
357+
add_cxx_compiler_flag("--coverage")
358+
add_cxx_compiler_flag("-O0")
359+
add_cxx_compiler_flag("-g")
360+
add_cxx_compiler_flag("-fno-inline")
361+
add_cxx_compiler_flag("-fno-inline-small-functions")
362+
add_cxx_compiler_flag("-fno-default-inline")
363+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage --coverage")
364+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fprofile-arcs -ftest-coverage --coverage")
365+
endif()
366+
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread")
367+
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address")
368+
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined")
369+
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=leak")
370+
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -finstrument-functions")
353371

354372
#Compilation database
355373
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
@@ -562,6 +580,7 @@ add_test(test-cells test-cells ${TEST_OPTIONS})
562580
add_test(test-smartcont test-smartcont)
563581
add_test(test-net test-net)
564582
add_test(test-actors test-tdactor)
583+
add_test(test-actors-coro tdactor/test/test-coro)
565584
add_test(test-emulator test-emulator)
566585

567586
#BEGIN tonlib

assembly/native/build-macos-portable.sh

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

assembly/native/build-macos-shared.sh

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