Skip to content

Commit 76662d3

Browse files
committed
refactor: Implement buffered event dispatch in tox_iterate.
Aligns the behaviour of events and non-events iterate code.
1 parent 8f5caa6 commit 76662d3

60 files changed

Lines changed: 1532 additions & 716 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

auto_tests/BUILD.bazel

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ cc_library(
1515
deps = [
1616
":check_compat",
1717
"//c-toxcore/testing:misc_tools",
18+
"//c-toxcore/toxcore",
1819
"//c-toxcore/toxcore:DHT",
1920
"//c-toxcore/toxcore:Messenger",
2021
"//c-toxcore/toxcore:mono_time",
2122
"//c-toxcore/toxcore:net_crypto",
2223
"//c-toxcore/toxcore:tox",
2324
"//c-toxcore/toxcore:tox_dispatch",
24-
"//c-toxcore/toxcore:tox_events",
2525
"//c-toxcore/toxcore:tox_log_level",
2626
],
2727
)
@@ -58,6 +58,7 @@ extra_data = {
5858
":check_compat",
5959
"//c-toxcore/testing:misc_tools",
6060
"//c-toxcore/toxav",
61+
"//c-toxcore/toxcore",
6162
"//c-toxcore/toxcore:Messenger",
6263
"//c-toxcore/toxcore:TCP_client",
6364
"//c-toxcore/toxcore:TCP_common",
@@ -80,8 +81,6 @@ extra_data = {
8081
"//c-toxcore/toxcore:os_random",
8182
"//c-toxcore/toxcore:tox",
8283
"//c-toxcore/toxcore:tox_dispatch",
83-
"//c-toxcore/toxcore:tox_events",
84-
"//c-toxcore/toxcore:tox_unpack",
8584
"//c-toxcore/toxcore:util",
8685
"//c-toxcore/toxencryptsave",
8786
"@libsodium",

auto_tests/scenarios/BUILD.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ cc_library(
88
visibility = ["//visibility:public"],
99
deps = [
1010
"//c-toxcore/testing:misc_tools",
11+
"//c-toxcore/toxcore",
1112
"//c-toxcore/toxcore:attributes",
1213
"//c-toxcore/toxcore:ccompat",
1314
"//c-toxcore/toxcore:mono_time",
1415
"//c-toxcore/toxcore:network",
1516
"//c-toxcore/toxcore:tox",
1617
"//c-toxcore/toxcore:tox_dispatch",
17-
"//c-toxcore/toxcore:tox_events",
1818
],
1919
)
2020

@@ -25,7 +25,7 @@ cc_library(
2525
deps = [
2626
":scenario_framework",
2727
"//c-toxcore/toxav",
28+
"//c-toxcore/toxcore",
2829
"//c-toxcore/toxcore:tox",
29-
"//c-toxcore/toxcore:tox_events",
3030
],
3131
) for src in glob(["scenario_*_test.c"])]

auto_tests/scenarios/framework/framework.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,6 @@ ToxNode *tox_scenario_add_node_ex(ToxScenario *s, const char *alias, tox_node_sc
577577
}
578578

579579
node->dispatch = tox_dispatch_new(nullptr);
580-
tox_events_init(node->tox);
581580
mono_time_set_current_time_callback(node->tox->mono_time, get_scenario_clock, s);
582581

583582
// Initial mirror population
@@ -784,7 +783,6 @@ void tox_node_reload(ToxNode *node)
784783

785784
ck_assert_msg(new_tox != nullptr, "tox_new said OK but returned NULL");
786785
Tox_Dispatch *new_dispatch = tox_dispatch_new(nullptr);
787-
tox_events_init(new_tox);
788786
mono_time_set_current_time_callback(new_tox->mono_time, get_scenario_clock, s);
789787

790788
pthread_mutex_lock(&s->mutex);

auto_tests/tox_dispatch_test.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ static void test_tox_events(void)
108108
for (uint32_t i = 0; i < 2; ++i) {
109109
index[i] = i + 1;
110110
toxes[i] = tox_new_log(nullptr, nullptr, &index[i]);
111-
tox_events_init(toxes[i]);
112111
ck_assert_msg(toxes[i] != nullptr, "failed to create tox instances %u", i);
113112
}
114113

other/docker/esp32/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ cc_binary(
99
"main/tox_main.h",
1010
],
1111
deps = [
12+
"//c-toxcore/toxcore",
1213
"//c-toxcore/toxcore:ccompat",
1314
"//c-toxcore/toxcore:tox",
14-
"//c-toxcore/toxcore:tox_events",
1515
],
1616
)

other/docker/modules/check

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ class BuildContext:
110110
def bzl_exports_files(self, *args: Any, **kwargs: Any) -> None:
111111
pass
112112

113-
def bzl_alias(self, *args: Any, **kwargs: Any) -> None:
114-
pass
113+
def bzl_alias(self, name: str, actual: str, **kwargs: Any) -> None:
114+
self._add_target(name, (), (), (actual, ))
115115

116116
def bzl_sh_library(self, *args: Any, **kwargs: Any) -> None:
117117
pass

other/event_tooling/generate_event_c.cpp

Lines changed: 114 additions & 40 deletions
Large diffs are not rendered by default.

testing/fuzzing/BUILD.bazel

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ cc_fuzz_test(
99
corpus = ["//tools/toktok-fuzzer/corpus:bootstrap_fuzz_test"],
1010
deps = [
1111
"//c-toxcore/testing/support",
12+
"//c-toxcore/toxcore",
1213
"//c-toxcore/toxcore:tox",
13-
"//c-toxcore/toxcore:tox_dispatch",
14-
"//c-toxcore/toxcore:tox_events",
1514
],
1615
)
1716

@@ -24,10 +23,9 @@ cc_fuzz_test(
2423
data = ["//tools/toktok-fuzzer/init:e2e_fuzz_test.dat"],
2524
deps = [
2625
"//c-toxcore/testing/support",
26+
"//c-toxcore/toxcore",
2727
"//c-toxcore/toxcore:crypto_core",
2828
"//c-toxcore/toxcore:tox",
29-
"//c-toxcore/toxcore:tox_dispatch",
30-
"//c-toxcore/toxcore:tox_events",
3129
],
3230
)
3331

@@ -49,9 +47,8 @@ cc_binary(
4947
copts = ["-UNDEBUG"],
5048
deps = [
5149
"//c-toxcore/testing/support",
50+
"//c-toxcore/toxcore",
5251
"//c-toxcore/toxcore:tox",
53-
"//c-toxcore/toxcore:tox_dispatch",
54-
"//c-toxcore/toxcore:tox_events",
5552
"//c-toxcore/toxcore:util",
5653
],
5754
)

testing/fuzzing/bootstrap_fuzz_test.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,6 @@ void TestBootstrap(Fuzz_Data &input)
190190
tox_bootstrap(tox, "127.0.0.2", 33446, pub_key, nullptr);
191191
tox_add_tcp_relay(tox, "127.0.0.2", 33446, pub_key, nullptr);
192192

193-
tox_events_init(tox);
194-
195193
Tox_Dispatch *dispatch = tox_dispatch_new(nullptr);
196194
assert(dispatch != nullptr);
197195
setup_callbacks(dispatch);

testing/fuzzing/e2e_fuzz_test.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,6 @@ void TestEndToEnd(Fuzz_Data &input)
202202
assert(error_new == TOX_ERR_NEW_OK);
203203
assert(error_new_testing == TOX_ERR_NEW_TESTING_OK);
204204

205-
tox_events_init(tox);
206-
207205
Tox_Dispatch *dispatch = tox_dispatch_new(nullptr);
208206
assert(dispatch != nullptr);
209207
setup_callbacks(dispatch);

0 commit comments

Comments
 (0)