Skip to main content
Filter by
Sorted by
Tagged with
18 votes
1 answer
2k views

I am trying to track if a C++20 coroutine has ever suspended, so that unhandled_exception knows whether it can simply re-throw; the exception back to the caller of the initial coroutine function, or ...
LB--'s user avatar
  • 3,228
1 vote
4 answers
97 views

There is something I can't understand in this code import asyncio async def fetch_data(param): print(f"Do something with {param}...") await asyncio.sleep(param) print(f"Done ...
M a m a D's user avatar
  • 2,189
2 votes
1 answer
180 views

The following code simulates short bursts of work by sleeping 1ms at a time in order to achieve a cancellable task that takes a total of 2s. That work is then launched in three different ways. The ...
Dalzhim's user avatar
  • 2,098
5 votes
1 answer
392 views

I am trying to use coroutines with Qt. Here's minimal(I guess) example to reproduce my problem Basically, bellow code is adopted from the example of cppreference here: https://en.cppreference.com/w/...
slyx's user avatar
  • 2,326
1 vote
1 answer
175 views

The following code attempts to create a simple stackful coroutine. It allocates a stack frame in the heap space by setting the rsp register and then calling a function. Afterwards, it exits the ...
algae's user avatar
  • 151
2 votes
0 answers
68 views

I'm trying to understand how memory is used in my async Python application. I have multiple coroutines running, and I want to see how much memory each one is using, especially when they are nested or ...
Optidev's user avatar
  • 218
0 votes
1 answer
91 views

I am trying to understand how async / await works from a high-level, semi-abstract perspective. There are quite a few long and complicated explanations of async / await online, some of which appear ...
SapereAude's user avatar
1 vote
0 answers
112 views

I'm writing some test code using Boost.Asio with C++20 coroutines. Working version (manual cleanup, non-RAII) The following code works as expected. Cleanup is always called, even when an exception is ...
Takatoshi Kondo's user avatar
-1 votes
1 answer
167 views

Let's assume I have a coroutine running on a strand. I would like the completion to be posted to the parent executor of the strand (i.e. : a thread_pool) while also releasing the strand. What is the ...
Dalzhim's user avatar
  • 2,098
1 vote
0 answers
90 views

I am trying to write a scheduler for a virtual computer that runs Lua and is transparent to the user (i.e.; no coroutine. yields needed) and would still like the user to be able to create coroutines ...
RRKS101_1 TF2's user avatar
2 votes
1 answer
125 views

I've tried std::enable_if and requires: template <typename Ret> struct promise_type { auto get_return_object() {/*...*/} auto initial_suspend() {/*...*/} auto return_void() -> std:...
shynur's user avatar
  • 505
3 votes
1 answer
107 views

In GCC 15, std::noop_coroutine's definition is { return std::noop_coroutine_handle(); } std::noop_coroutine_handle is defined by: using noop_coroutine_handle = std::coroutine_handle<std::...
shynur's user avatar
  • 505
2 votes
0 answers
92 views

Basically, the whole idea is something like the Task implementation in C# where functions can return Task<T> that callers can await on. For some reason, TestFuncAsync runs correctly the first 2 ...
InfiniPLEX's user avatar
-7 votes
1 answer
267 views

I would like to know whether Cgo implementing functions are allowed to arbitrarily manipulate the stack pointer. The motivation for this is to allow the use of coroutines on the C side of the call. ...
Hammdist's user avatar
  • 214
0 votes
0 answers
77 views

In python, one can replace for [...] in [generator] by async for [...] in [awaitable generator]. Clearly, this lowers the overall execution time of a program if the [generator] contains some slow I/O ...
dimitsev's user avatar
  • 137
0 votes
1 answer
60 views

I want to modify this log helper function to print out coroutine id or name. @JvmInline value class MyLogger(private val tag: String) { fun log(level: Level, e: Throwable? = null, ...
Cindy's user avatar
  • 273
4 votes
1 answer
158 views

I've read through the documentation of std::generator<T> and found no mention of thread-safety. Now essentially I have a co-routine that generates work elements and I want to consume them with ...
BrainStone's user avatar
  • 3,215
1 vote
1 answer
100 views

I am currently running a C++ program in which I have used the heap to simulate the stack and employed assembly language to place relevant information (such as memory addresses) into registers, thereby ...
qingfu liu's user avatar
0 votes
2 answers
64 views

I wanted to add a if condition to my coroutine and it broke it private void OnTriggerEnter(Collider other) { if (other.CompareTag("Water")) { isSwimming = true; rb....
Harry Birch's user avatar
1 vote
1 answer
72 views

I am profiling some code using the cppgraphgqlgen library - which uses C++20 coroutines extensively in its internals. I have profiled an application and found that I have some called-into methods that ...
Andrew Lipscomb's user avatar
2 votes
1 answer
61 views

Where is task to process big list of items in sequential-parallel way: split big list to chunks, process chunks one after another, process items from each chunk in parallel. Implementing this task, I ...
An12's user avatar
  • 21
1 vote
3 answers
134 views

I have a code: import asyncio as aio async def coro(future: aio.Future): print('Coro start') await aio.sleep(3) print('Coro finish') future.set_result('coro result') async def main(): ...
IzaeDA's user avatar
  • 439
3 votes
1 answer
191 views

AFAICT there is no builtin way in C++20 or C++23 to globally query the promise or handle for the coroutine running on the current thread. However any of the functions that let you return a coroutine ...
Joseph Garvin's user avatar
0 votes
0 answers
49 views

I'm struggling with running python-telegram-bot-21.10 as a coroutine to a PyQt5 application using Python-3.12.7 (intended to run on a Raspberry Pi). I had this setting operating for some years now ...
blue14's user avatar
  • 56
3 votes
1 answer
91 views

This article presents this pseudocode for how the compiler transforms a coroutine function: ReturnType someCoroutine(Parameters parameter) { auto* frame = new coroutineFrame(std::forward<...
Joseph Garvin's user avatar
2 votes
1 answer
55 views

In Lua, I can define a member function like this: Foo = {} function Foo:bar() ... end I realise this is just syntactic sugar for this: Foo = {} foo.bar = function(self) ... end Is there a way ...
Tom's user avatar
  • 8,171
6 votes
2 answers
2k views

I'm facing an issue with my Google Sign-In implementation in an Android application. I have two pieces of code: the first one works correctly, while the second one fails during the call to ...
Yoon's user avatar
  • 81
2 votes
1 answer
121 views

It is often said that coroutines could be thought of as "light threads" because they consume less memory. However, I wasn't able to find any explanation on why exactly that is the case. What ...
DiplomateProgrammer's user avatar
1 vote
0 answers
81 views

I’m attempting to optimize a binary search workload using C++ coroutines on a 1GB sorted array of unique random integers to induce multiple memory misses. The approach involves using co_await when ...
Hod Badihi's user avatar
1 vote
1 answer
144 views

I want to know a method to pass values from the caller to the coroutine. My idea: Any awaiter type must provide a await_resume() function. This function can return something to the co_await inside ...
Klaus's user avatar
  • 26k
-1 votes
1 answer
68 views

I'm very new to coding and am trying to make a basic simon says game. Currently I have a cube that is supposed to change the material after a few seconds however I'm really struggling getting any sort ...
Jelita Purches's user avatar
0 votes
0 answers
96 views

So far the best I've come up with is a wrapper function for every function, like this: template<class A, class B> coro<var> operator+(A && a, B && b) { return [] (A a, ...
kylefinn's user avatar
  • 2,423
0 votes
0 answers
56 views

I'm using the MongoDB Kotlin Driver dependency. My project run with Spring Boot but I don't want to use the Spring Data MongoDB dependency (So as not to be dependant on Spring). I use a bean to ...
ValentinJDT's user avatar
2 votes
0 answers
159 views

I try to implement a simple coroutine using c. The platform is: M3 Pro MacBook Pro 16 apple native gcc macOS 14.3.1 Here is my code: // main.c #include <stdio.h> #include <stdlib.h> #...
JasonZhang's user avatar
2 votes
0 answers
80 views

I have a server and a client. The server is responsible for forking child processes and interacting with them to get log outputs to send to the client. It also receives input from the client and sends ...
Jarviswu's user avatar
2 votes
2 answers
117 views

godbolt: https://godbolt.org/z/6avWcGqKv The following code, compiled and run with g++ 12, 13, 14, all give the same (wrong?) output. clang 18, 19 are fine (all "done: 1"). As far as I ...
Ralph Zhang's user avatar
  • 5,443
2 votes
3 answers
177 views

I have implemented my own experimental coroutine awaiter object to grasp the awaiter rationale. I call a coroutine which is foo in my example. In await_suspend method, I invoked a thread and this ...
Cabbas's user avatar
  • 101
1 vote
1 answer
51 views

I have a very simple coroutine example to understand basics. However, I am stuck to understand why the done method of the handle object still returns false. I call resume and there is no more co_await ...
Cabbas's user avatar
  • 101
-1 votes
1 answer
68 views

Sometimes I need to consume everything that a generator outputs but don't actually need the output. In one case, some callers need progress updates from a coroutine, but some callers don't; in another ...
zmccord's user avatar
  • 2,603
0 votes
1 answer
164 views

In this code: private suspend fun doSthSingleThreaded(){ coroutineScope { //Coroutine 1 launch { //do sth that will suspend } //Coroutine 2 ...
khebrati's user avatar
  • 100
0 votes
1 answer
129 views

In the following code, I build a coroutine in scope1 using launch. I set its job to be instance of Job, so any children's cancellation will cause the parent job to be cancelled. I used awaitAll which, ...
windchime's user avatar
  • 1,295
1 vote
0 answers
45 views

While diving into Android/Kotlin development, I learned that the suspend keyword transforms the function into a state machine that can be removed from its executing thread, put on hold, and resumed at ...
ErnestV's user avatar
  • 137
3 votes
2 answers
132 views

I got a processing class that signals a certain condition via a callback that is bound late at runtime. The processing class is executed by a coroutine, and the signal wants to call a coroutine ...
Superlokkus's user avatar
  • 5,159
1 vote
3 answers
104 views

I have var DICTIONARY, which is a dictionary where the keys are English letters and the values are words that start with the corresponding letter. The initial filling of DICTIONARY looks like this: ...
ERJAN's user avatar
  • 24.6k
-1 votes
1 answer
48 views

i have var DICTIONARY, which is a dictionary where the keys are English letters and the values are words that start with the corresponding letter. The initial filling of DICTIONARY looks like this: ...
ERJAN's user avatar
  • 24.6k
0 votes
0 answers
47 views

I have a really weird bug where I have a function that resets my whole room. First, it clears the previous grids if they exist. Then, it generates lists of lists of vectors, which work as grids. Then ...
MarcosT's user avatar
0 votes
0 answers
60 views

This code works fine. using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; class Enemy { public string enemyName = "Default Enemy Name&...
papyrus's user avatar
0 votes
1 answer
79 views

I have class MyViewModel(private val activitiesRepo: ActivitiesRepo) : ViewModel() { val activities = mutableStateListOf<Activity>() private var activitiesFlow = activitiesRepo....
wuujcik's user avatar
  • 66
1 vote
1 answer
279 views

I'm using sol2 (v3.3.0) in C++ to run Lua coroutines. I want to pass a Lua function to C++ and execute it as a coroutine. However, my attempts to convert sol::function to sol::coroutine are not ...
Harumaki's user avatar
3 votes
1 answer
96 views

I am new to corotine and asio. I am working on a local process management tool where a client is responsible for launching a program. This client sends commands to a backend daemon that manages the ...
Jarviswu's user avatar

1
2 3 4 5
48