|
From: woodcock on 1 May 2008 16:08 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...
From: Joseph M. Newcomer on 1 May 2008 16:23 CSingleLock is a poorly-designed and worse-implemented mechanism; in fact, it is so badly done that it is nearly insane to consider using it for any purpose whatsoever. Also, too much locking is usually a sign of a needlessly-complex design; locked should be done rarely because there should be very little concurrent access between threads, preferrably none at all, but in the rare cases where it is used, there should be very little "work" done; preferrably a number of lines measurable by a single-digit integer. But I have avoided Unix for close to 20 years now, so I have fortunately never needed to worry about issues of portability to 1960s operating systems. joe On Thu, 1 May 2008 13:08:59 -0700 (PDT), 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... Joseph M. Newcomer [MVP] email: newcomer(a)flounder.com Web: http://www.flounder.com MVP Tips: http://www.flounder.com/mvp_tips.htm
|
Pages: 1 Prev: MDAC memory leak Next: a globally shared variable among dlls? |