21 TEST(rpc, compilation_tests) {
23 server.
BindSync(
"bind00", []() {
return 2.0f; });
24 server.
BindSync(
"bind01", [](
int x) {
return x; });
25 server.
BindSync(
"bind02", [](
int,
float) {
return 0.0; });
26 server.
BindSync(
"bind03", [](
int,
float,
double,
char) {});
29 TEST(rpc, server_bind_sync_run_on_game_thread) {
30 const auto main_thread_id = std::this_thread::get_id();
36 server.
BindSync(
"do_the_thing", [=](
int x,
int y) ->
int {
37 EXPECT_EQ(std::this_thread::get_id(), main_thread_id);
43 std::atomic_bool done{
false};
47 Client client(
"localhost", port);
48 for (
auto i = 0; i < 300; ++i) {
49 auto result = client.
call(
"do_the_thing", i, 1).as<
int>();
50 EXPECT_EQ(result, i + 1);
56 for (; i < 1
'000'000u; ++i) {
62 std::cout <<
"game thread: run " << i <<
" slices.\n";
void AsyncRun(size_t worker_threads)
constexpr uint16_t TESTING_PORT
void BindSync(const std::string &name, FunctorT &&functor)
void CreateThread(F &&functor)
auto call(const std::string &function, Args &&... args)
An RPC server in which functions can be bind to run synchronously or asynchronously.
TEST(rpc, compilation_tests)
void SyncRunFor(time_duration duration)