diff --git a/builtin-functions/kphp-light/rpc.txt b/builtin-functions/kphp-light/rpc.txt index 83a2b7d5a..c5bce048d 100644 --- a/builtin-functions/kphp-light/rpc.txt +++ b/builtin-functions/kphp-light/rpc.txt @@ -33,16 +33,16 @@ final class KphpRpcRequestsExtraInfo { } /** @kphp-extern-func-info interruptible */ -function rpc_send_request($actor ::: string, $arr ::: array, $timeout ::: float, $ignore_answer ::: bool, \KphpRpcRequestsExtraInfo $requests_extra_info, $need_responses_extra_info ::: bool) ::: int[]; +function rpc_send_requests($actor ::: string, $arr ::: array, $timeout ::: float, $ignore_answer ::: bool, \KphpRpcRequestsExtraInfo $requests_extra_info, $need_responses_extra_info ::: bool) ::: int[]; /** @kphp-extern-func-info interruptible */ -function rpc_send_typed_query_request($actor ::: string, @tl\RpcFunction[] $query_functions, $timeout ::: float, $ignore_answer ::: bool, \KphpRpcRequestsExtraInfo $requests_extra_info, $need_responses_extra_info ::: bool) ::: int[]; +function rpc_send_typed_query_requests($actor ::: string, @tl\RpcFunction[] $query_functions, $timeout ::: float, $ignore_answer ::: bool, \KphpRpcRequestsExtraInfo $requests_extra_info, $need_responses_extra_info ::: bool) ::: int[]; /** @kphp-extern-func-info interruptible */ -function rpc_fetch_response($query_ids ::: array) ::: mixed[][]; +function rpc_fetch_responses($query_ids ::: array) ::: mixed[][]; /** @kphp-extern-func-info interruptible */ -function rpc_fetch_typed_response(int[] $query_ids) ::: @tl\RpcResponse[]; +function rpc_fetch_typed_responses(int[] $query_ids) ::: @tl\RpcResponse[]; /** @kphp-extern-func-info can_throw */ function fetch_int () ::: int; diff --git a/runtime-common/stdlib/math/math-functions.cpp b/runtime-common/stdlib/math/math-functions.cpp index 144a912f6..f53499105 100644 --- a/runtime-common/stdlib/math/math-functions.cpp +++ b/runtime-common/stdlib/math/math-functions.cpp @@ -6,7 +6,7 @@ #include -mixed f$abs(const mixed &v) { +mixed f$abs(const mixed &v) noexcept { mixed num = v.to_numeric(); if (num.is_int()) { return std::abs(num.to_int()); @@ -14,23 +14,23 @@ mixed f$abs(const mixed &v) { return fabs(num.to_float()); } -int64_t f$abs(int64_t v) { +int64_t f$abs(int64_t v) noexcept { return std::abs(v); } -double f$abs(double v) { +double f$abs(double v) noexcept { return std::abs(v); } -int64_t f$abs(const Optional &v) { +int64_t f$abs(const Optional &v) noexcept { return f$abs(val(v)); } -int64_t f$abs(const Optional &v) { +int64_t f$abs(const Optional &v) noexcept { return f$abs(static_cast(val(v))); } -double f$abs(const Optional &v) { +double f$abs(const Optional &v) noexcept { return f$abs(val(v)); } diff --git a/runtime-common/stdlib/math/math-functions.h b/runtime-common/stdlib/math/math-functions.h index 60987c373..e4b569cd8 100644 --- a/runtime-common/stdlib/math/math-functions.h +++ b/runtime-common/stdlib/math/math-functions.h @@ -6,73 +6,73 @@ #include "runtime-common/core/runtime-core.h" -inline double f$ceil(double v); +inline double f$ceil(double v) noexcept; -inline double f$cos(double v); +inline double f$cos(double v) noexcept; -inline double f$deg2rad(double v); +inline double f$deg2rad(double v) noexcept; -inline double f$floor(double v); +inline double f$floor(double v) noexcept; -inline double f$log(double v); +inline double f$log(double v) noexcept; -inline double f$log(double v, double base); +inline double f$log(double v, double base) noexcept; template -inline T f$min(const array &a); +inline T f$min(const array &a) noexcept; template -inline T f$max(const array &a); +inline T f$max(const array &a) noexcept; template -inline T f$min(const T &arg1); +inline T f$min(const T &arg1) noexcept; template -inline T f$min(const T &arg1, const T &arg2, Args&&... args); +inline T f$min(const T &arg1, const T &arg2, Args&&... args) noexcept; template -inline T f$max(const T &arg1); +inline T f$max(const T &arg1) noexcept; template -inline T f$max(const T &arg1, const T &arg2, Args&&... args); +inline T f$max(const T &arg1, const T &arg2, Args&&... args) noexcept; -inline double f$pi(); +inline double f$pi() noexcept; -inline double f$round(double v, int64_t precision = 0); +inline double f$round(double v, int64_t precision = 0) noexcept; -inline double f$sqrt(double v); +inline double f$sqrt(double v) noexcept; -mixed f$abs(const mixed &v); -int64_t f$abs(int64_t v); -double f$abs(double v); -int64_t f$abs(const Optional &v); -int64_t f$abs(const Optional &v); -double f$abs(const Optional &v); +mixed f$abs(const mixed &v) noexcept; +int64_t f$abs(int64_t v) noexcept; +double f$abs(double v) noexcept; +int64_t f$abs(const Optional &v) noexcept; +int64_t f$abs(const Optional &v) noexcept; +double f$abs(const Optional &v) noexcept; -inline double f$ceil(double v) { +inline double f$ceil(double v) noexcept { return ceil(v); } -inline double f$cos(double v) { +inline double f$cos(double v) noexcept { return cos(v); } -inline double f$deg2rad(double v) { +inline double f$deg2rad(double v) noexcept { return v * M_PI / 180; } -inline double f$floor(double v) { +inline double f$floor(double v) noexcept { return floor(v); } -inline double f$log(double v) { +inline double f$log(double v) noexcept { if (v <= 0.0) { return 0.0; } return log(v); } -inline double f$log(double v, double base) { +inline double f$log(double v, double base) noexcept { if (v <= 0.0 || base <= 0.0 || fabs(base - 1.0) < 1e-9) { return 0.0; } @@ -80,7 +80,7 @@ inline double f$log(double v, double base) { } template -T f$min(const array &a) { +T f$min(const array &a) noexcept { if (a.count() == 0) { php_warning("Empty array specified to function min"); return T(); @@ -97,7 +97,7 @@ T f$min(const array &a) { } template -T f$max(const array &a) { +T f$max(const array &a) noexcept { if (a.count() == 0) { php_warning("Empty array specified to function max"); return T(); @@ -114,30 +114,30 @@ T f$max(const array &a) { } template -T f$min(const T &arg1) { +T f$min(const T &arg1) noexcept { return arg1; } template -T f$min(const T &arg1, const T &arg2, Args&& ...args) { +T f$min(const T &arg1, const T &arg2, Args&& ...args) noexcept { return f$min(lt(arg1, arg2) ? arg1 : arg2, std::forward(args)...); } template -T f$max(const T &arg1) { +T f$max(const T &arg1) noexcept { return arg1; } template -T f$max(const T &arg1, const T &arg2, Args&& ...args) { +T f$max(const T &arg1, const T &arg2, Args&& ...args) noexcept { return f$max(lt(arg2, arg1) ? arg1 : arg2, std::forward(args)...); } -inline double f$pi() { +inline double f$pi() noexcept { return M_PI; } -inline double f$round(double v, int64_t precision) { +inline double f$round(double v, int64_t precision) noexcept { if (std::abs(precision) > 100) { php_warning("Wrong parameter precision (%" PRIi64 ") in function round", precision); return v; @@ -147,7 +147,7 @@ inline double f$round(double v, int64_t precision) { return round(v * mul) / mul; } -inline double f$sqrt(double v) { +inline double f$sqrt(double v) noexcept { if (v < 0) { return 0.0; } diff --git a/runtime-light/stdlib/rpc/rpc-api.cpp b/runtime-light/stdlib/rpc/rpc-api.cpp index ef7246a30..de2e113d5 100644 --- a/runtime-light/stdlib/rpc/rpc-api.cpp +++ b/runtime-light/stdlib/rpc/rpc-api.cpp @@ -358,7 +358,7 @@ string f$fetch_string() noexcept { // === Rpc Query ================================================================================== -task_t> f$rpc_send_request(string actor, array tl_objects, double timeout, bool ignore_answer, +task_t> f$rpc_send_requests(string actor, array tl_objects, double timeout, bool ignore_answer, class_instance requests_extra_info, bool need_responses_extra_info) noexcept { if (ignore_answer && need_responses_extra_info) { php_warning("Both $ignore_answer and $need_responses_extra_info are 'true'. Can't collect metrics for ignored answers"); @@ -380,7 +380,7 @@ task_t> f$rpc_send_request(string actor, array tl_objects, co_return query_ids; } -task_t>> f$rpc_fetch_response(array query_ids) noexcept { +task_t>> f$rpc_fetch_responses(array query_ids) noexcept { array> res{query_ids.size()}; for (const auto &it : query_ids) { res.set_value(it.get_key(), co_await rpc_impl_::rpc_tl_query_result_one_impl(it.get_value())); diff --git a/runtime-light/stdlib/rpc/rpc-api.h b/runtime-light/stdlib/rpc/rpc-api.h index b3c70f954..44e6de255 100644 --- a/runtime-light/stdlib/rpc/rpc-api.h +++ b/runtime-light/stdlib/rpc/rpc-api.h @@ -59,11 +59,11 @@ string f$fetch_string() noexcept; // === Rpc Query ================================================================================== - task_t> f$rpc_send_request(string actor, array tl_objects, double timeout = -1.0, bool ignore_answer = false, + task_t> f$rpc_send_requests(string actor, array tl_objects, double timeout = -1.0, bool ignore_answer = false, class_instance requests_extra_info = {}, bool need_responses_extra_info = false) noexcept; template rpc_function_t, std::same_as rpc_request_t = KphpRpcRequest> -task_t> f$rpc_send_typed_query_request(string actor, array> query_functions, double timeout = -1.0, +task_t> f$rpc_send_typed_query_requests(string actor, array> query_functions, double timeout = -1.0, bool ignore_answer = false, class_instance requests_extra_info = {}, bool need_responses_extra_info = false) noexcept { if (ignore_answer && need_responses_extra_info) { @@ -87,11 +87,11 @@ task_t> f$rpc_send_typed_query_request(string actor, array>> f$rpc_fetch_response(array query_ids) noexcept; +task_t>> f$rpc_fetch_responses(array query_ids) noexcept; template query_id_t = int64_t, std::same_as error_factory_t = RpcResponseErrorFactory> requires std::default_initializable task_t>> -f$rpc_fetch_typed_response(array query_ids) noexcept { +f$rpc_fetch_typed_responses(array query_ids) noexcept { array> res{query_ids.size()}; for (const auto &it : query_ids) { res.set_value(it.get_key(), co_await rpc_impl_::typed_rpc_tl_query_result_one_impl(it.get_value(), error_factory_t{})); diff --git a/tests/k2-components/test_rpc_memcached.php b/tests/k2-components/test_rpc_memcached.php index 254db83f1..7074c6d32 100644 --- a/tests/k2-components/test_rpc_memcached.php +++ b/tests/k2-components/test_rpc_memcached.php @@ -1,24 +1,24 @@ "memcache.get", "key" => "xxx"]]); - $response = rpc_fetch_response($ids)[0]; + $ids = rpc_send_requests("mc_main", [["_" => "memcache.get", "key" => "xxx"]]); + $response = rpc_fetch_responses($ids)[0]; $result = $response["result"]; if ($result["_"] !== "memcache.not_found") { warning("memcache.not_found expected"); return false; } - $ids = rpc_send_request("mc_main", [["_" => "memcache.set", "key" => "foo", "flags" => 0, "delay" => 0, "value" => "bar"]]); - $response = rpc_fetch_response($ids)[0]; + $ids = rpc_send_requests("mc_main", [["_" => "memcache.set", "key" => "foo", "flags" => 0, "delay" => 0, "value" => "bar"]]); + $response = rpc_fetch_responses($ids)[0]; $result = $response["result"]; if ($result !== true) { warning("true expected"); return false; } - $ids = rpc_send_request("mc_main", [["_" => "memcache.get", "key" => "foo"]]); - $response = rpc_fetch_response($ids)[0]; + $ids = rpc_send_requests("mc_main", [["_" => "memcache.get", "key" => "foo"]]); + $response = rpc_fetch_responses($ids)[0]; $result = $response["result"]; if ($result["_"] !== "memcache.strvalue" || $result["value"] !== "bar") { warning("\"bar\" expected");