admin管理员组文章数量:1122826
I'm wondering if there is a way to run some async task in the background while other processing is happening in Hacklang, and then once the other processing is done, check if the result from the other async task is complete, and use the response if it is? There are some time sensitive things that need to be done, that can't be blocking.
public async function doStuff() {
$background_res = doSomethingAsync();
// do a bunch of important processing
// get result of $background_res if it completed, if not move on
}
I'm wondering if there is a way to run some async task in the background while other processing is happening in Hacklang, and then once the other processing is done, check if the result from the other async task is complete, and use the response if it is? There are some time sensitive things that need to be done, that can't be blocking.
public async function doStuff() {
$background_res = doSomethingAsync();
// do a bunch of important processing
// get result of $background_res if it completed, if not move on
}
Share
Improve this question
asked Nov 23, 2024 at 4:30
tallkid24tallkid24
1,8094 gold badges17 silver badges21 bronze badges
1 Answer
Reset to default 1In Hack, you can await multiple tasks at once:
concurrent{
$background_awaitable = await doSomethingAsync();
$important_result = await importantProcessing();
}
However, this will wait until all are done before continuing. If you want to not wait until both are done, you will need to look into a separate threading library
本文标签: Running async task in the background in HacklangStack Overflow
版权声明:本文标题:Running async task in the background in Hacklang - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736299849a1930606.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论