Skip to content

Commit

Permalink
Add cancellations (#1055)
Browse files Browse the repository at this point in the history
* add cancellable awaitables
* add start fork policy
* make RPC use forks
  • Loading branch information
apolyakov authored Aug 13, 2024
1 parent 152e60b commit f8139d0
Show file tree
Hide file tree
Showing 14 changed files with 581 additions and 218 deletions.
4 changes: 2 additions & 2 deletions compiler/code-gen/vertex-compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ void compile_func_call(VertexAdaptor<op_func_call> root, CodeGenerator &W, func_

if (mode == func_call_mode::fork_call) {
if (func->is_interruptible) {
W << "(co_await start_fork_and_reschedule_t{" << FunctionName(func);
W << "(co_await start_fork_t{" << FunctionName(func);
} else {
W << FunctionForkName(func);
}
Expand Down Expand Up @@ -883,7 +883,7 @@ void compile_func_call(VertexAdaptor<op_func_call> root, CodeGenerator &W, func_
W << ")";
if (func->is_interruptible) {
if (mode == func_call_mode::fork_call) {
W << "})";
W << ", start_fork_t::execution::fork})";
} else if (func->is_k2_fork) { // k2 fork's return type is 'task_t<fork_result>' so we need to unpack actual result from fork_result
W << ").get_result<" << TypeName(tinf::get_type(root)) << ">()";
} else {
Expand Down
13 changes: 13 additions & 0 deletions runtime-core/utils/hash.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Compiler for PHP (aka KPHP)
// Copyright (c) 2024 LLC «V Kontakte»
// Distributed under the GPL v3 License, see LICENSE.notice.txt

#include <cstddef>
#include <functional>

// from boost
// see https://www.boost.org/doc/libs/1_55_0/doc/html/hash/reference.html#boost.hash_combine
template<typename T>
void hash_combine(size_t &seed, const T &v) noexcept {
seed ^= std::hash<T>{}(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
Loading

0 comments on commit f8139d0

Please sign in to comment.