Debian Codegraph @

src/coro_loop/coro_loop.cpp

raw symbols SCIP
1 /************************************************************************************
2 *
3 * D++, A Lightweight C++ library for Discord
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 * Copyright 2021 Craig Edwards and D++ contributors
7 * (https://github.com/brainboxdotcc/DPP/graphs/contributors)
8 *
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
12 *
13 * http://www.apache.org/licenses/LICENSE-2.0
14 *
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 *
21 ************************************************************************************/
22
23 #include <dpp/dpp.h>cxx . . $ `<file>/include/dpp/dpp.h`/
24 #include <iostream>
25
26 int64_t proc_self_valuecxx . . $ proc_self_value(cbd3d91d7922f5e).(const stdcxx . . $ std/::stringcxx . . $ std/string#& find_token) {
27 int64_t ret = 0;
28 stdcxx . . $ std/::ifstreamcxx . . $ std/ifstream# self_statuscxx . . $ std/basic_ifstream#basic_ifstream(b8cd37071ce335df).("/proc/self/status");
29 while (self_status) {
30 stdcxx . . $ std/::stringcxx . . $ std/string# tokencxx . . $ std/__cxx11/basic_string#basic_string(925dcc5e17f50391).;
31 self_status >>cxx . . $ std/`operator>>`(567ac654e2f44b5d). token;
32 if (token ==cxx . . $ std/`operator==`(5ea818b58063a774). find_token) {
33 self_status >>cxx . . $ std/basic_istream#`operator>>`(927c60e123e2de33). ret;
34 break;
35 }
36 }
37 self_status.closecxx . . $ std/basic_ifstream#close(49f6e7a06ebc5aa8).();
38 return ret;
39 }
40
41 int64_t rsscxx . . $ rss(da6335ded91d79c2).() {
42 return proc_self_valuecxx . . $ proc_self_value(cbd3d91d7922f5e).("VmRSS:"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).) * 1024;
43 }
44
45 #ifndef DPP_NO_CORO
46 dppcxx . . $ dpp/::taskcxx . . $ dpp/task#<void> testcxx . . $ test(de90adce4e148c07).(dppcxx . . $ dpp/::clustercxx . . $ dpp/cluster#& cluster) {
47 [[maybe_unused]] int test[102400]{};
48 test[60] = 5;
49 co_return;
50 }
51 #endif
52
53 int maincxx . . $ main(b126dc7c1de90089).() {
54 #ifndef DPP_NO_CORO
55 char* t = getenv("DPP_UNIT_TEST_TOKEN");
56 if (t) {
57 dppcxx . . $ dpp/::clustercxx . . $ dpp/cluster# coro_clustercxx . . $ dpp/cluster#cluster(13cb741d36ace229).(tcxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d)., dppcxx . . $ dpp/::i_guildscxx . . $ dpp/i_guilds., 1, 0, 1, true, dppcxx . . $ dpp/::cache_policycxx . . $ dpp/cache_policy/::cpol_nonecxx . . $ dpp/cache_policy/cpol_none.);
58 coro_cluster.set_websocket_protocolcxx . . $ dpp/cluster#set_websocket_protocol(af3c514d5e977a71).(dppcxx . . $ dpp/::ws_etfcxx . . $ dpp/ws_etf.);
59 coro_cluster.on_logcxx . . $ dpp/cluster#on_log.(cxx . . $ dpp/event_router_t#`operator()`(7d840609c6f74506).dppcxx . . $ dpp/::utilitycxx . . $ dpp/utility/::cout_loggercxx . . $ dpp/utility/cout_logger(1e13570ddc4c0e10).());
60 coro_cluster.on_readycxx . . $ dpp/cluster#on_ready.(cxx . . $ dpp/event_router_t#`operator()`(7d840609c6f74506).[&coro_cluster](auto) -> dppcxx . . $ dpp/::taskcxx . . $ dpp/task#<void> {
61 coro_cluster.start_timercxx . . $ dpp/cluster#start_timer(9d1304a91436eb94).([&coro_cluster](dppcxx . . $ dpp/::timercxx . . $ dpp/timer#) -> dppcxx . . $ dpp/::taskcxx . . $ dpp/task#<void> {
62 for (int i = 0; i < 1000; ++i) {
63 co_await testcxx . . $ test(de90adce4e148c07).(coro_cluster);
64 }
65 coro_cluster.logcxx . . $ dpp/cluster#log(7f5f639e8434218f).(dppcxx . . $ dpp/::ll_infocxx . . $ dpp/ll_info., "coro timer ticked. RSS=" +cxx . . $ std/operator+(39ed2c165380f78e). stdcxx . . $ std/::to_stringcxx . . $ std/__cxx11/to_string(2c88ed78ff9aa4cf).(rsscxx . . $ rss(da6335ded91d79c2).()));
66 co_return;
67 }, 1);
68 co_return;
69 });
70 coro_cluster.startcxx . . $ dpp/cluster#start(fa7c3f1aeb8ff3e5).(dppcxx . . $ dpp/::st_waitcxx . . $ dpp/st_wait.);
71 }
72 #endif
73 }