Home » Developing U++ » UppHub » Coroutines package for U++
Re: Coroutines package for U++ [message #59293 is a reply to message #59292] |
Mon, 12 December 2022 17:42   |
Oblivion
Messages: 1206 Registered: August 2007
|
Senior Contributor |
|
|
Hello zsolt
Quote:Is it possible some easy way to write a function / method to start rendering some big images or PDFs on other threads and awaiting them, to complete, not blocking the main (GUI) thread, that started it?
In my experience the real question would be: Will it worth it?
My answer would be: No. Because what you describe is already achievable by using Upp::CoWork or Upp::AsyncWork. You can offload a rendering operation using these tools without blocking the gui, check their status and wait for them to join in non-blocking way and cancel them when you need to (AsyncWork has a Cancel method). In fact, I have a small utility (app) called SshGet (an MT Sftp/Scp transfer queque), where I do someting very similar to what you describe (instead of rendering stuff, I am transfering them).
However, the direct answer to your questions is that it is partially possible. cpp/coroutines have a concept called awaitables. You can write an awaitable type (class or functor) and pass the coroutine handle among threads in a lock free way via awaitable. But 1) It is complicated, 2) It wont solve the real problem: termination of a thread. Plus, what you achive in the end will seem to be what CoWork et al. can already do.
This is the reason why I opted to implement a light-weight coroutines interface (only routine and generator types and not the awaitable type.) This makes things simple and clean.
Best regards,
Oblivion
Github page: https://github.com/ismail-yilmaz
upp-components: https://github.com/ismail-yilmaz/upp-components
Bobcat the terminal emulator: https://github.com/ismail-yilmaz/Bobcat
[Updated on: Mon, 12 December 2022 17:45] Report message to a moderator
|
|
|
 |
|
Coroutines package for U++
By: Oblivion on Sat, 05 November 2022 12:19
|
 |
|
Re: Coroutines package for U++
By: Oblivion on Sun, 06 November 2022 20:20
|
 |
|
Re: Coroutines package for U++
By: Klugier on Sun, 06 November 2022 20:44
|
 |
|
Re: Coroutines package for U++
By: Oblivion on Sun, 06 November 2022 21:31
|
 |
|
Re: Coroutines package for U++
By: Lance on Mon, 07 November 2022 00:14
|
 |
|
Re: Coroutines package for U++
By: koldo on Mon, 07 November 2022 08:39
|
 |
|
Re: Coroutines package for U++
By: Oblivion on Mon, 07 November 2022 20:07
|
 |
|
Re: Coroutines package for U++
By: peterh on Mon, 07 November 2022 20:30
|
 |
|
Re: Coroutines package for U++
By: Oblivion on Mon, 07 November 2022 20:31
|
 |
|
Re: Coroutines package for U++
By: peterh on Tue, 08 November 2022 09:09
|
 |
|
Re: Coroutines package for U++
By: Oblivion on Wed, 09 November 2022 16:22
|
 |
|
Re: Coroutines package for U++
By: Oblivion on Wed, 09 November 2022 22:52
|
 |
|
Re: Coroutines package for U++
By: Lance on Wed, 09 November 2022 23:26
|
 |
|
Re: Coroutines package for U++
By: Lance on Sat, 12 November 2022 00:33
|
 |
|
Re: Coroutines package for U++
By: Oblivion on Sat, 12 November 2022 07:22
|
 |
|
Re: Coroutines package for U++
By: Lance on Sun, 13 November 2022 05:37
|
 |
|
Re: Coroutines package for U++
By: Lance on Mon, 14 November 2022 02:17
|
 |
|
Re: Coroutines package for U++
By: Oblivion on Mon, 14 November 2022 05:56
|
 |
|
Re: Coroutines package for U++
By: Lance on Mon, 14 November 2022 15:08
|
 |
|
Re: Coroutines package for U++
By: peterh on Mon, 07 November 2022 18:38
|
 |
|
Re: Coroutines package for U++
By: zsolt on Mon, 12 December 2022 13:48
|
 |
|
Re: Coroutines package for U++
By: Oblivion on Mon, 12 December 2022 17:42
|
 |
|
Re: Coroutines package for U++
By: zsolt on Mon, 12 December 2022 21:38
|
Goto Forum:
Current Time: Sat May 10 19:35:02 CEST 2025
Total time taken to generate the page: 0.03256 seconds
|