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 » PROPOSAL: Monitor mutex in objects
Re: PROPOSAL: Monitor mutex in objects [message #27443 is a reply to message #27378] Sun, 18 July 2010 09:05 Go to previous message
mirek is currently offline  mirek
Messages: 14267
Registered: November 2005
Ultimate Member
kohait00 wrote on Thu, 15 July 2010 05:42

hi guys,

in C# there exists a nice feature,
lock(objectinstance)
{
//method code on now protected object
}

one can protect another object of beeing somehow accessed / modified, while oneself is treating with it. the object itself doesnt know about that and does not need to take care on providing any synchonisation features inside.

would it be possible to make something like that in upp as well?
as far as i know, c# compiler helps here somehow..

meanwhile:

here is another maybe usefull construction, came in mind while i was dealing with Mt.h..

#define LOCKER UPP::Mutex __locker
#define LOCKED INTERLOCKED_(__locker)

class MyClass
{
	void Method()
	{
		LOCKED
		{
		//your per object locked code
		}
	}
};
private:
	LOCKER;
}

it's unlicke the pure INTERLOCKED, which would generate a StaticMutex in every method the LOCKED is used.

if it is sensefull...


class MyClass {
    Mutex lock;
    void Method() {
       INTERLOCKED_(lock) {
           ...
       }
    }
};


or (usually I like that more)

class MyClass {
    Mutex lock;
    void Method() {
       Mutex::Lock __(lock);
       ...
    }
};


I do not think we really need more...
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Stop Download
Next Topic: Problem when compiling multiple threads
Goto Forum:
  


Current Time: Tue Aug 26 16:17:39 CEST 2025

Total time taken to generate the page: 0.05366 seconds