Surtan
Posts: 1
Joined: 17 Aug 2017, 15:35

Re: C++ Noesis and multithreading

27 Aug 2017, 12:48

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.
 
nikobarli
Posts: 180
Joined: 26 Apr 2017, 06:23

Re: C++ Noesis and multithreading

29 Aug 2017, 05:37

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.
 
User avatar
sfernandez
Site Admin
Posts: 2991
Joined: 22 Dec 2011, 19:20

Re: C++ Noesis and multithreading

30 Aug 2017, 13:14

Thanks @nikobarli, you explained it perfectly.
 
Wanderer
Topic Author
Posts: 168
Joined: 08 May 2017, 18:36

Re: C++ Noesis and multithreading

10 Apr 2018, 22:07

Are there plans for multithreading support in 2.1+ version?
 
User avatar
jsantos
Site Admin
Posts: 3918
Joined: 20 Jan 2012, 17:18
Contact:

Re: C++ Noesis and multithreading

10 Apr 2018, 23:04

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.
 
Wanderer
Topic Author
Posts: 168
Joined: 08 May 2017, 18:36

Re: C++ Noesis and multithreading

11 Apr 2018, 11:05

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)
// 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);
DependencyProperty is static, I think it is safe to use it in another thread? If I understand threading correctly.
 
User avatar
jsantos
Site Admin
Posts: 3918
Joined: 20 Jan 2012, 17:18
Contact:

Re: C++ Noesis and multithreading

11 Apr 2018, 11:07

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)
 
Wanderer
Topic Author
Posts: 168
Joined: 08 May 2017, 18:36

Re: C++ Noesis and multithreading

11 Apr 2018, 11:23

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?
 
User avatar
jsantos
Site Admin
Posts: 3918
Joined: 20 Jan 2012, 17:18
Contact:

Re: C++ Noesis and multithreading

11 Apr 2018, 11:47

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