Re: Assertion failures in wincvsView.cpp (Trunk / 2.0.3)?

"kaczoroj" <[email protected]> Mon, 06 Feb 2006 01:12:19 -0000
Newsgroups gmane.comp.version-control.cvs.gui.devel
Message-ID <[email protected]>
Arthur,

Critical section is supposed to be much faster than Mutex, perhaps 
better to just do Lock() instead.

Best Regards,
Jerzy

--- In [email protected], "Arthur Barrett" <arthur.barrett@.
..> wrote:
>
>  
> Hi all!
>  
> Just having a look at the code on the trunk (2.0.3 I think) and I 
think
> I've found problem with the use of CSingleLock and CCriticalSection 
-
> basically the code is passing a timeout which is not permitted in 
that
> context - so in debug mode I get a lot of assertion failure in
> afx(blah-blah-blah)dot(blah).  The same problem seems to be 
discussed
> here (warning - lots of adverts and you can only visit this page 
once
> per day without registering):
> http://www.experts-exchange.com/Programming/Programming_Languages/
MFC/Q_
> 21711876.html
>  
> The MSDN documentation is clear as mud on this issue - there 
certainly
> is a lot of "suggestion" that non-infiinite numbers with a
> CriticalSection do not make sense, but nothing in black and white - 
and
> in non-debug mode there is no evidence that the call actually fails
...
> The closest is here (because CSingleLock on a CCriticalSection will
> ultimately call CCriticalSection:Lock() anyway - but I'd hardly call
> this proof:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/
vclib/h
> tml/_mfc_ccriticalsection.asp
>  
> "If timed waits are necessary, you can use a CMutex
> <http://msdn.microsoft.com/library/en-us/vclib/html/_mfc_cmutex.asp>
> object instead of a CCriticalSection object."
>  
> Provided that the speed of wincvsView() is not critical then I 
suggest
> that my mods are probably a better way to handle sync (see attached
> context diff - also pasted below).
>  
> Regards,
>  
>  
> Arthur
>  
>  
>  
> Index: wincvsView.cpp
> ===================================================================
> RCS file: /cvsroot/cvsgui/cvsgui/WinCvs/wincvsView.cpp,v
> retrieving revision 1.24
> diff -c -r1.24 wincvsView.cpp
> *** wincvsView.cpp 19 Dec 2004 14:39:32 -0000 1.24
> --- wincvsView.cpp 5 Feb 2006 21:58:58 -0000
> ***************
> *** 72,77 ****
> --- 72,80 ----
>   CWincvsView::CWincvsView()
>   {
>    m_fRtfFormat = ::RegisterClipboardFormat(_T("Rich Text Format"));
> + #ifdef MARCH_HARE_MODS
> +     m_pMutex = new CMutex(FALSE);
> + #endif /* MARCH_HARE_MODS */
>    
>    m_sbuf = 0L;
>    m_snumbuf = 0;
> ***************
> *** 91,96 ****
> --- 94,102 ----
>    {
>     app->StopScriptEngine();
>    }
> + #ifdef MARCH_HARE_MODS
> +     delete m_pMutex;
> + #endif /* MARCH_HARE_MODS */
>   }
>   
>   /// PreCreateWindow virtual override, modify the window style
> ***************
> *** 352,358 ****
> --- 358,368 ----
>   void CWincvsView::OutColor(const char* txt, long len)
>   {
>    // Synchronize
> + #ifdef MARCH_HARE_MODS
> +  CSingleLock lock(m_pMutex);
> + #else
>    CSingleLock lock(&m_syncObject);
> + #endif /* MARCH_HARE_MODS */
>    if( !lock.Lock(20000) )
>    {
>     ASSERT(FALSE); // Lock failed
> ***************
> *** 389,395 ****
> --- 399,409 ----
>   void CWincvsView::OutColor(kConsoleColor color)
>   {
>    // Synchronize
> + #ifdef MARCH_HARE_MODS
> +  CSingleLock lock(m_pMutex);
> + #else
>    CSingleLock lock(&m_syncObject);
> + #endif /* MARCH_HARE_MODS */
>    if( !lock.Lock(20000) )
>    {
>     ASSERT(FALSE); // Lock failed
> ***************
> *** 450,456 ****
> --- 464,474 ----
>   void CWincvsView::OutColor(WCHARFORMAT& format)
>   {
>    // Synchronize
> + #ifdef MARCH_HARE_MODS
> +  CSingleLock lock(m_pMutex);
> + #else
>    CSingleLock lock(&m_syncObject);
> + #endif /* MARCH_HARE_MODS */
>    if( !lock.Lock(20000) )
>    {
>     ASSERT(FALSE); // Lock failed
> ***************
> *** 470,476 ****
> --- 488,498 ----
>   void CWincvsView::OutConsole(const char* txt, long len, bool 
isStderr
> /*= false*/)
>   {
>    // Synchronize
> + #ifdef MARCH_HARE_MODS
> +  CSingleLock lock(m_pMutex);
> + #else
>    CSingleLock lock(&m_syncObject);
> + #endif /* MARCH_HARE_MODS */
>    if( !lock.Lock(20000) )
>    {
>     ASSERT(FALSE); // Lock failed
> Index: wincvsView.h
> ===================================================================
> RCS file: /cvsroot/cvsgui/cvsgui/WinCvs/wincvsView.h,v
> retrieving revision 1.12
> diff -c -r1.12 wincvsView.h
> *** wincvsView.h 2 Jan 2004 01:42:39 -0000 1.12
> --- wincvsView.h 5 Feb 2006 21:58:58 -0000
> ***************
> *** 144,150 ****
> --- 144,154 ----
>    int m_snumbuf;  /*!< Print buffer size */
>    UINT m_fRtfFormat; /*!< Clipboard format */
>   
> + #ifdef MARCH_HARE_MODS
> +     CMutex* m_pMutex; /*!< A better output synchronization object
 ? */
> + #else
>    CCriticalSection m_syncObject; /*!< Output synchronization object 
*/
> + #endif /* MARCH_HARE_MODS */
>   
>    // Methods
>    virtual HRESULT QueryAcceptData(LPDATAOBJECT, CLIPFORMAT*, DWORD,
> BOOL, HGLOBAL);
> 
> 
> 
> [Non-text portions of this message have been removed]
>






 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/cvsgui-dev/

<*> To unsubscribe from this group, send an email to:
    [email protected]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/