Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » U++ community news and announcements » Major redesign of MT in GUI
Major redesign of MT in GUI [message #21382] Sat, 16 May 2009 19:40 Go to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Up to now, the only allowed interaction with non-main threads and GUI was through sending events.

The new approach introduces "Ctrl::EnterMutex" and "Ctrl::LeaveMutex" methods that can be used to protect shared access to any widget (and helper class Ctrl::Lock that does so on for block using contructors/destructors).

Means accessing widget data or changing widget content in non-main thread is now much more simple.

For now (maybe only today Smile, there are certain methods that cannot be called by non-main thread - those that deal with opening new windows and events (event loops). It is because in Win32 it is impossible (for U++) to run them in any other thread than main.

I will probably resolve this situation by performing such requests in main thread.... (via new planned "Ctrl::Call function that will make possible to 'call' code in main thread while waiting for its completition).

Mirek
Re: Major redesign of MT in GUI [message #21385 is a reply to message #21382] Sun, 17 May 2009 12:43 Go to previous messageGo to next message
kodos is currently offline  kodos
Messages: 111
Registered: March 2008
Experienced Member
If there is no performance hit, this sounds really interesting! Smile
Re: Major redesign of MT in GUI [message #21386 is a reply to message #21385] Sun, 17 May 2009 14:40 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
kodos wrote on Sun, 17 May 2009 06:43

If there is no performance hit, this sounds really interesting! Smile


I believe there is almost no performance hit as long as most of GUI is performed in main thread Smile

But of course, all of that needs some locking.

Mirek
Re: Major redesign of MT in GUI [message #21387 is a reply to message #21386] Sun, 17 May 2009 16:30 Go to previous messageGo to next message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

Does it mean tha each Ctrl will have it`s own Mutex object?
Re: Major redesign of MT in GUI [message #21390 is a reply to message #21387] Sun, 17 May 2009 23:11 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Actually, there is single mutex for everything. That is required by X11 anyway and semi-required by Win32.

In fact, after some thinking, I have decided to scratch the idea of "per widget" locking and replace this global mutex available.

Also, Ctrl::Call is now implemented and thus you can absolutely anything in threads with GUI (but some things are being performed in main thread using Call).

So the final rule for MT GUI programming is pretty simple:

If you are going to call any method or GUI function, you have to lock the scope using GuiLock helper guard (or EnterGuiMutex/LeaveGuiMutex pair).

Mirek
Previous Topic: Code Navigator refactored
Next Topic: SVN UPDATE & .deb BUILD : Revision 951 - 2009-03-12
Goto Forum:
  


Current Time: Sat Apr 20 03:57:35 CEST 2024

Total time taken to generate the page: 0.02554 seconds