|
From: Nick Meyer on 2 May 2008 09:18 "woodcock(a)sonlightsoftware.com" wrote: > I am porting a very simple Windows MFC (VisualStudio) C++ project > (single screen GUI tool to generate socket traffic to a proprietary > system) to Linux. It makes CRAZY use of MFC CSingleLock like this:n > > CCriticalSection m_MyLockHandle; > > MyClass::MyCriticalFunc() > { > CSingleLock singleLock(&m_MyLockHandle); > singleLock.Lock(); > /* Bunch of work here on shared objects */ > singleLock.Unlock(); > } > > Is there a straightforward replacement mechanism within ACE for this? > If not, what is the simplest way to achieve this form of basic object > locking (synchronization) in gcc (or third party class/library)? Even > if ACE can do this, it is probably overkill (I'm not using any other > ACE facilities) so the 2nd question (other simple way) is still of > interest to me even if ACE can do it tidily... > You might want to look into the class template ACE_Guard<T>. It works in a similar way, and releases the lock on destruction to ensure that if an exception is thrown you don't leave the lock hanging. HTH, Nick
|
Pages: 1 Prev: List of available serial ports Next: transparent window after bringWindowToTop is grey |