CriticalSection( const CriticalSection& other );
CriticalSection& operator = ( const CriticalSection& other );
};
} // namespace nick
#endif // __NICK__CRITICAL_SECTION__K_IN_G__
//例子:
CriticalSection cs;
int i = 0;
int
main()
{
LOCK(cs,
for (i=0;i < 1000;i++)
//do some thing
)
}
//other thread:
LOCK(cs,
for (i=1000;i < 2000;++i)
// do other thing;
)
//实现了使用 i 上的安全性
//不用写什么Enter Leave了,直接一个LOCK宏搞定,不过g++对于宏内部
//方面的支持有问题,不支持宏实参里面带分号(不知道最新的版本支持吗)
//但是.net 中没有问题