Тёмный
No video :(

How to calculate long tasks in GUI code (C++, Dear ImGui) 

Zen Sepiol
Подписаться 2,3 тыс.
Просмотров 2,6 тыс.
50% 1

This video shows how to calculate long tasks in a separate thread to avoid framerate drops in GUI code.
Tools that I use:
www.virtualbox.org/
kubuntu.org/
code.visualstudio.com/
llvm.org/
clang.org/
mesonbuild.com/index.html
In code:
github.com/renatoGarcia/icecr...
github.com/ZenSepiol
github.com/ocornut/imgui
github.com/epezent/implot

Опубликовано:

 

29 апр 2023

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 21   
@sedenion9524
@sedenion9524 Месяц назад
If the heavy computation is an opengl GPU render, how to deal with it ?
@aviadsp
@aviadsp Год назад
Thank you.. you need to handle scenario when the long calculation is really long, and the user can click many times on that button, without results from the first click. the question is if you can assign new std::future to the object when the old object still in progress
@ZenSepiol
@ZenSepiol Год назад
This is correct. The behavior of std::future is, that is has to be finished before it can be reassigned. Otherwise, it will block the reassignment for as long as the old future needs to finish. Making it perfectly save, I would introduce a deque to store a new future every single time the button is clicked. Additionally, I would add some logic to limit the number of futures which are executed in parallel to avoid launching too many threads.
@AnishPednekar
@AnishPednekar 5 месяцев назад
I'm reading a very large csv file (~500mb) and making a sweeping animated plot using ImPlot. This is really helpful to offload the csv parsing to a separate thread. Thanks! I have a question though, how is future_result.wait_for not blocking the GUI thread? Is it skipped over if the task is not yet complete and then re run at the next iteration of Update()?
@ZenSepiol
@ZenSepiol 5 месяцев назад
Yes exactly. It is possible to specify a timeout, when the future will return. No timeout means it returns immediately in case the background job has not finished processing.
@duribv
@duribv Год назад
This is _exactly_ what I need. Sorry I did not have time to test your suggestions for the "docking" branch and my last attempt failed as I remember :P Nevertheless, I do not get the point of "wait_for" - where does the choice of 1ms come from? This seems like program uncertainity. Will it work without it?
@ZenSepiol
@ZenSepiol Год назад
The wait_for is necessary to not block the main thread. The main thread arrives at the "wait_for" and stays there for 1ms or until the other thread has calculated the result. After the time, it moves on. You can even set 0ms there and it should work fine.
@duribv
@duribv Год назад
@@ZenSepiol So the GUI frame rendering is deliberately delayed 1 ms as I understand. Isn't the 0 ms a better choice then?
@ZenSepiol
@ZenSepiol Год назад
Yes, 0ms would be better.
@StevenMartinGuitar
@StevenMartinGuitar Год назад
Do you have any experience with using ImGui inside something like the MVC, MVVC, MVP patterns etc? I find it tricky to seperate business logic and data from UI logic because of how ImGui is set up
@ZenSepiol
@ZenSepiol Год назад
The main concept of ImGui is that you can use the gui related code directly where you need it. In larger projects I usually use dependency injection to pass the render queue down the hirarchy. Do you have a specific MVC example that I should replicate in ImGui?
@nrwchd
@nrwchd Год назад
cool video. could you do "worker and task" next?
@ZenSepiol
@ZenSepiol Год назад
This has been on my list for some time. Will come soon!
@nrwchd
@nrwchd Год назад
@@ZenSepiol will be waiting!
@wjrasmussen666
@wjrasmussen666 Год назад
TDD with IMGui. MySQL and edit data examples.
@ZenSepiol
@ZenSepiol Год назад
TDD with gui is always challenging, I'll see what I can do! Databases are a good suggestion, thanks!
@gentoogentoo4476
@gentoogentoo4476 Год назад
Thank you for the great videos! Is there any way to support your channel directly through donations? I use RSS feed to subscribe so I cannot support your channel through YT subscription.
@ZenSepiol
@ZenSepiol Год назад
Thank you so much :-) Means a lot to me and any support is highly appreciated! There should be the option to use the so called "Super Thanks" below any video to donate to the channel. I don't know if this is usable to you though.
@gentoogentoo4476
@gentoogentoo4476 Год назад
@@ZenSepiol I think setting up an account on services like "Buy Me a Coffee" could be useful for you. I heard that RU-vid takes a lot from the donations.
@ZenSepiol
@ZenSepiol Год назад
I will look into it! Did read today, that RU-vid takes 30%. I‘ll let you know once I find the time. Great hint!
@ZenSepiol
@ZenSepiol Год назад
I have set it up. Again, thanks for the hint! www.buymeacoffee.com/ZenSepiol
Далее
How to use Googletest and Meson to build C++ tests
5:55
How to write Thread Pools in C++
13:37
Просмотров 8 тыс.
ПОМОГЛА НАЗЫВАЕТСЯ😂
00:20
Просмотров 2 млн
Это iPhone 16
00:52
Просмотров 915 тыс.
BEST WAY to make Desktop Applications in C++
26:00
Просмотров 900 тыс.
C++ vs Rust: which is faster?
21:15
Просмотров 386 тыс.
Gtk vs Qt | GUI tool kits | Which is Better?
7:06
Просмотров 34 тыс.
The Dark Side of C++ - Copy-On-Write
8:39
Просмотров 1,9 тыс.
All Rust string types explained
22:13
Просмотров 159 тыс.
ПОМОГЛА НАЗЫВАЕТСЯ😂
00:20
Просмотров 2 млн