critsect.h

来自「The library provides supports for run-ti」· C头文件 代码 · 共 46 行

H
46
字号
#ifndef CRITSECT_H#define CRITSECT_H// A fast critical section / mutex class// It will work under Gcc using AtomicAdd or under// Windows using InterlockedIncrement. For other platforms// a replacement for this atomic increment must be found.class CritSect {public:	// If using the crit sect statically or globally, 	// set do_construct to false, then it can be used	// correctly without init (it works well from the	// zero state)	CritSect( bool do_construct=true );	void Enter( );	void Leave( );	bool TryEnter( );protected:	int m_cnt;	// Allocated count.	int m_thid;	// Thread ID of owner};class CritSectLocker {public:	CritSectLocker( CritSect &cs ) : m_cs(cs) { m_cs.Enter(); }	~CritSectLocker( ) { m_cs.Leave(); }	CritSect &m_cs;};// Should have this name reallytypedef CritSect piCritSect;// For backwards compatibility#ifdef WXWIDGETStypedef CritSect wxCritSect;typedef CritSectLocker wxCritSectLocker;#endif#endif // CRITSECT_H

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?