-
Notifications
You must be signed in to change notification settings - Fork 88
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
Exception (and thread) safety/awareness of hello_imgui question #17
Comments
Hello, hello_imgui does not use exceptions and does not make any assumptions about them being present or not. So I guess you can do whatever you like.
Yes.
hello_imgui does not launch any thread at all. |
Thanks. To be able to use exceptions (and C++ does use them by default itself) or threads I must be sure the environment allows it. Imgui is almost a plane C library that does nothing about such support but it allows access to all the internals and do not have (or do not have many) callbacks that may throw. But as far as hello_imgui hides some internals and is built around the users’ callbacks (as I see from hello_world example) it shall provide exception safe guarantees or be aware about exceptions (allow a user somehow handle them and make hello_imgui intact). The same is valid about thread safeness – you are either thread safe or aware about threads (i.e. you provide some synchronization primitives that your clients may use).
I do understand it. But the real applications inevitably do and your clients must know what to expect and how use hello_imgui in multi-threaded environment with exceptions. |
If you look at the API overview, you will see these callbacks: What
The wording "callback" is thus perhaps not quite appropriate, but be assured that these callbacks are synchronous. So in summary,
|
Ok, thank you. I see that in case of an error I have to invent some program behavior that would not crash the program. I cannot just throw an exception and stop thinking about the broken frame anymore. I can wrap the Imgui’s begin/end C-style paradigm with my own exception safe helpers but hello_imgui looks different and I am not sure I could use it the same way. |
Well, the callbacks that you provide are supposed to be consisting of mainly only GUI code (I.e ImGui calls). The business code should belong elsewhere, as for any program where the GUI is separated from the rest. You could plug signals and slots between callbacks and your business code for example (using Qt or boost::signal) |
Hello. Imgui itself is not exception safe or exceptions aware but I know how to deal with this mainly C code. What is about hello_imgui? I consider it as a kind of window management system for Imgui that hides some its mechanics so I must be sure I may or may not use exceptions with hello_imgui.
Sorry for the noob question but it is a blocker for me so I want to be sure about the facts, approaches and plans. Thank you.
P.S. It would be worth to mention about thread safety/awareness too.
The text was updated successfully, but these errors were encountered: