-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest_deadlock.cpp
76 lines (53 loc) · 2.48 KB
/
test_deadlock.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Copyright (c) 2016-2024 Knuth Project developers.
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <kth/capi/node.h>
#include <iostream>
#include <chrono>
#include <thread>
int main() {
std::cout << "Initializing...\n";
// using (var node = new Knuth.Node("node.cfg")) {
// auto node = kth_node_construct_fd("/Users/fernando/dev/kth/cs-api/console/node.cfg", 0, 0);
auto node = kth_node_construct_fd("/Users/fernando/dev/kth/cs-api/console/node_throttling.cfg", 0, 0);
{
// var result = await node.InitAndRunAsync();
// kth_node_init_and_run(node, handlerPtr, internalRunNodeHandler_);
auto result = kth_node_init_and_run_wait(node);
if (result != 0) {
std::cout << "kth_node_init_and_run_wait failed; error code: " << result << std::endl;
std::cout << "sleeping 5 seconds" << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(5));
}
// kth_node_close(node);
std::cout << "main thread: " << std::this_thread::get_id() << std::endl;
std::thread t1([&] {
std::cout << "t1 thread: " << std::this_thread::get_id() << std::endl;
kth_node_close(node);
});
t1.join();
}
}
// void history_fetch_handler(int error, history_compact_list_t list) {
// // printf("C callback (history_fetch_handler) called\n");
// // printf("Calling Python callback\n");
// PyObject* arglist = Py_BuildValue("(iO)", error, history_list);
// PyObject* result = PyObject_CallObject(global_callback, arglist);
// Py_DECREF(arglist);
// }
// int main(int argc, char* argv[]) {
// kth_node_t exec = kth_node_construct("/home/fernando/exec/btc-mainnet.cfg", stdout, stderr);
// int res1 = kth_node_initchain(exec);
// int res2 = kth_node_run(exec);
// // fetch_merkle_block_by_height(exec, 0, NULL);
// fetch_history(exec, "134HfD2fdeBTohfx8YANxEpsYXsv5UoWyz", 0, 0, history_fetch_handler);
// using namespace std::chrono_literals;
// std::cout << "Hello waiter" << std::endl;
// auto start = std::chrono::high_resolution_clock::now();
// std::this_thread::sleep_for(2s);
// auto end = std::chrono::high_resolution_clock::now();
// std::chrono::duration<double, std::milli> elapsed = end-start;
// std::cout << "Waited " << elapsed.count() << " ms\n";
// kth_node_destruct(exec);
// return 0;
// }