Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[k2] implement wait_concurrently #1223

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 35 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
94871d1
get rid of clangd warnings
apolyakov Jan 16, 2025
374060d
put INVALID_FORK_ID under kphp::forks namespace
apolyakov Jan 20, 2025
05646a7
change ForkInstanceState's interface
apolyakov Jan 20, 2025
7e7112f
remove unused code from task_t
apolyakov Jan 22, 2025
87dc593
add task_t::when_ready
apolyakov Jan 22, 2025
095a2e2
add missing using awaiter_base_t::awaiter_base_t
apolyakov Jan 22, 2025
11cb16b
use php_assert instead of assert in task_t
apolyakov Jan 22, 2025
45763e9
mark task_t::operator co_await noexcept
apolyakov Jan 22, 2025
64470f1
refactor task_t
apolyakov Jan 23, 2025
46abf21
remove unused include from awaitable.h
apolyakov Jan 23, 2025
8bdc3c8
remove unused include from fork-state.h
apolyakov Jan 23, 2025
561af81
mark more methods in task_t noexcept
apolyakov Jan 23, 2025
954412f
add [[unlikely]] inside task_t::get_result
apolyakov Jan 23, 2025
81b927d
add more noexcepts
apolyakov Jan 23, 2025
3f1efd9
a bit of task_t refactoring
apolyakov Jan 24, 2025
1970843
move coroutine type traits into a separate file
apolyakov Jan 24, 2025
d073190
implement shared_task_t -- the new coroutine type
apolyakov Jan 27, 2025
722d67a
add shared_task_t to coroutine type traits
apolyakov Jan 27, 2025
1aaa1e0
implement wait_concurrently
apolyakov Jan 27, 2025
f57b25b
call cancel from start_fork_t::await_suspend if needed
apolyakov Jan 27, 2025
6dadf51
add critical error for the case of cancellation of shared_task after …
apolyakov Jan 27, 2025
4d0833e
add new test for wait_concurrently
apolyakov Jan 27, 2025
ce14c6c
make start_fork_t change the current fork ID
apolyakov Jan 28, 2025
09dac26
add std::remove_cv_ref_t to the type of start_fork_t::fork_awaiter
apolyakov Jan 28, 2025
b9fe966
a bit of refactoring of shared_task_t::destroy
apolyakov Jan 28, 2025
0b06e84
return wait_fork_t to correctly manage current fork ID
apolyakov Jan 28, 2025
52f859e
add comment about having two distinct wait_fork awaiters
apolyakov Jan 28, 2025
766ef31
use symmetric transfer in shared_task_t::final_suspend::await_suspend
apolyakov Jan 28, 2025
a9463bb
get rid of exceptions in shared_task_t
apolyakov Jan 28, 2025
83bfddc
don't pass m_coro into promise::suspend
apolyakov Jan 28, 2025
dbdd217
add TODO about using double-linked list as a container of shared_task…
apolyakov Jan 28, 2025
cc3a971
mark shared_task_t::operator co_await const
apolyakov Jan 29, 2025
72b217d
rename shared_task.h -> shared-task.h
apolyakov Feb 7, 2025
f616075
rename a few methods of shared_task::promise_type
apolyakov Feb 7, 2025
35f79ac
rework start_fork_t
apolyakov Feb 7, 2025
42ec1de
change the order of members in promise_base_t
apolyakov Feb 11, 2025
d670c4e
Revert "change the order of members in promise_base_t"
apolyakov Feb 11, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions builtin-functions/kphp-light/functions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ function get_running_fork_id() ::: future <void>;
/** @kphp-extern-func-info interruptible cpp_template_call */
function wait(future<any> | false $id, float $timeout = -1.0) ::: ^1[*] | null;

/** @kphp-extern-func-info interruptible */
function wait_concurrently ($id ::: future<any>): bool;

// === Fork =======================================================================================

/** @kphp-extern-func-info interruptible */
Expand Down
2 changes: 0 additions & 2 deletions builtin-functions/kphp-light/unsupported/fork.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

function wait_concurrently ($id ::: future<any>) ::: bool;

/** @kphp-extern-func-info can_throw cpp_template_call */
function wait_multi (future<any>[] $resumables) ::: (^1[*][*] | null)[];

Expand Down
3 changes: 2 additions & 1 deletion compiler/code-gen/declarations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ void FunctionDeclaration::compile(CodeGenerator &W) const {
case gen_out_style::tagger:
case gen_out_style::cpp: {
if (function->is_interruptible) {
FunctionSignatureGenerator(W) << "task_t<" << ret_type_gen << ">" << " " << FunctionName(function) << "(" << params_gen << ")";
FunctionSignatureGenerator(W) << "task_t<" << ret_type_gen << ">" << " " << FunctionName(function) << "("
<< params_gen << ")";
} else {
FunctionSignatureGenerator(W) << ret_type_gen << " " << FunctionName(function) << "(" << params_gen << ")";
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/code-gen/vertex-compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,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_t{static_cast<task_t<void>>(" << FunctionName(func);
W << "(co_await start_fork_t{" << FunctionName(func);
} else {
W << FunctionForkName(func);
}
Expand Down Expand Up @@ -935,7 +935,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 << "), start_fork_t::execution::fork})";
W << "})";
} else {
W << ")";
}
Expand Down
Loading
Loading