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 » U++ Library support » U++ MT-multithreading and servers » GuiLock and GuiUnlock objects are of different type.
GuiLock and GuiUnlock objects are of different type. [message #56195] Sun, 07 February 2021 17:49 Go to next message
Oblivion is currently offline  Oblivion
Messages: 1136
Registered: August 2007
Senior Contributor
Hi,

GuiLock is defined as a struct, and GuiUnlock as a class. I think the source code should be consistent.

My recommendation:
class GuiLock { // <--- changed struct to class
public:         // <--- added.
        GuiLock()  { EnterGuiMutex(); }
        ~GuiLock() { LeaveGuiMutex(); }
};

class GuiUnlock {
	int n;

public:
	GuiUnlock()  { n = LeaveGuiMutexAll(); }
	~GuiUnlock() { EnterGuiMutex(n); }
};




Best regards,
Oblivion


Re: GuiLock and GuiUnlock objects are of different type. [message #56196 is a reply to message #56195] Sun, 07 February 2021 17:58 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 14112
Registered: November 2005
Ultimate Member
Oblivion wrote on Sun, 07 February 2021 17:49
Hi,

GuiLock is defined as a struct, and GuiUnlock as a class. I think the source code should be consistent.

My recommendation:
class GuiLock { // <--- changed struct to class
public:         // <--- added.
        GuiLock()  { EnterGuiMutex(); }
        ~GuiLock() { LeaveGuiMutex(); }
};

class GuiUnlock {
	int n;

public:
	GuiUnlock()  { n = LeaveGuiMutexAll(); }
	~GuiUnlock() { EnterGuiMutex(n); }
};




Best regards,
Oblivion


IDK. I am using struct in almost all cases where either all members are naturally public or I do not care about hiding by private (which is 99% of time in end applications). Is that wrong? For me the difference between struct and class is the default access, nothing else...

Re: GuiLock and GuiUnlock objects are of different type. [message #56197 is a reply to message #56196] Sun, 07 February 2021 18:02 Go to previous message
Oblivion is currently offline  Oblivion
Messages: 1136
Registered: August 2007
Senior Contributor
Quote:


IDK. I am using struct in almost all cases where either all members are naturally public or I do not care about hiding by private (which is 99% of time in end applications). Is that wrong? For me the difference between struct and class is the default access, nothing else...


Effectively, nothing is wrong there, it is solely about access type, of course. As I noted, it is just for the sake of some consistency in source code. And source code parsers (intellisense, et.c) may categorize them differently. It "may" impair the visiblity of the "lock pair".

Best regards,
Oblivion


[Updated on: Sun, 07 February 2021 18:03]

Report message to a moderator

Previous Topic: Urr Data not properly returned in our case
Next Topic: How to Sync computer Time in a network?
Goto Forum:
  


Current Time: Sun Nov 10 20:19:12 CET 2024

Total time taken to generate the page: 0.00403 seconds