Re: C++ Noesis and multithreading
What's the max number of threads you can use guys?
Last edited by Surtan on 19 Jan 2018, 12:24, edited 2 times in total.
Re: C++ Noesis and multithreading
As far as I know, it's your choice. As of v2.0, NoesisGUI doesn't create threads by its own. It's your responsibility to create the thread(s) and call the necessary APIs.
Ref: https://www.noesisengine.com/docs/Gui.C ... orial.html
The simplest configuration is to assign one thread to act as both Main thread and Render thread, for all the views.
If you need more performance, you can create two threads, one acts as Main thread and another acts as Render thread.
If your Render thread is still too busy, you can choose to use multiple Render threads, each is responsible to render one or more of the views.
If your Main thread is still too busy, you can choose to use multiple Main threads, each is responsible to interact with/update one or more of the views.
So maybe the answer to your question is, if you have n views, you can have at max n Main threads and n Render threads.
Ref: https://www.noesisengine.com/docs/Gui.C ... orial.html
The simplest configuration is to assign one thread to act as both Main thread and Render thread, for all the views.
If you need more performance, you can create two threads, one acts as Main thread and another acts as Render thread.
If your Render thread is still too busy, you can choose to use multiple Render threads, each is responsible to render one or more of the views.
If your Main thread is still too busy, you can choose to use multiple Main threads, each is responsible to interact with/update one or more of the views.
So maybe the answer to your question is, if you have n views, you can have at max n Main threads and n Render threads.
-
sfernandez
Site Admin
- Posts: 2991
- Joined:
Re: C++ Noesis and multithreading
Thanks @nikobarli, you explained it perfectly.
Re: C++ Noesis and multithreading
Are there plans for multithreading support in 2.1+ version?
Re: C++ Noesis and multithreading
NoesisGUI already supports multi-threading (since v2.0). Views can be executed while their render is happening in a different thread. We don't plan to support multi-threading for the View, like for example interacting with a button in one thread and with a slider in a different thread, both element belonging to the same View. That would be very inefficient to handle.
Re: C++ Noesis and multithreading
And what about databinding? It is safe to use DependencyProperty on second thread to update GUI? In my previous post I wrote I got error on console when I use function from diferent thread (to update UI). Now I test DependencyProperty and I don't get any error on console and program runing without problem. Even with function from my noesis object. (I use Noesis 2.1.0f1 version)
DependencyProperty is static, I think it is safe to use it in another thread? If I understand threading correctly.
Code: Select all
// this functions are called from second thread
m_NsContainerItem->SetValue<NsString>(m_NsContainerItem->dp_FilePath_SourceName, m_Source.filename().u8string().c_str());
m_NsContainerItem->mf_GetPropertyCHanged()->mf_set_button_item_file_open_error_visibility(Noesis::Visibility::Visibility_Visible);
Re: C++ Noesis and multithreading
No, that is not safe. Even if you don't get an error. You must always invoke NoesisGUI from the same thread (with the exception of the rendering stuff)
Re: C++ Noesis and multithreading
The safety means access to DependencyProperty while it is called from second thread? For example when I call this code which I showed, something can call from main thread and it can crash or corrupt data?
Re: C++ Noesis and multithreading
It means you cannot interact in any way with the API, reading or writing. It may work but we do not guarantee that. You should protect the access in your code.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 13 guests