bug-commoncpp
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re[2]: win32 ost::Mutex class ideology missing


From: Andrey Kulikov
Subject: Re[2]: win32 ost::Mutex class ideology missing
Date: Fri, 25 Jun 2004 14:04:49 +0400

Hello David,

DS> I do not recall offhand, but are critical sections recursive?


As i understand, recursive means that one thread can lock
synchronization object only once, and following next attempts to lock
in the same thread will be ignored.
(Ok, not ignored, but deadlock will be avoided).

With my changes in ost::Mutex this program
==============================
#include "stdafx.h"
#include <cc++/thread.h>
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
        ost::Mutex mtx;

        cout << "1" << endl;
        mtx.enterMutex();
        cout << "2" << endl;
        mtx.enterMutex();
        cout << "3" << endl;
        mtx.leaveMutex();
        cout << "4" << endl;
        mtx.leaveMutex();
        cout << "5" << endl;
        return 0;
}
==============================

Produces output
==============================
1
2
3
4
5
==============================

i.e. deadlock by second enterMutex in the same thread not appears.

Is this correct?


-- 
Best regards,
 Andrey                            mailto:address@hidden





reply via email to

[Prev in Thread] Current Thread [Next in Thread]