当前位置:网站首页>MFC multithreaded semaphore csemaphore critical area and mutually exclusive events
MFC multithreaded semaphore csemaphore critical area and mutually exclusive events
2022-06-24 07:26:00 【Little yellow man software】
CMutex, CCriticalSection For mutually exclusive access to resources .
CMutex Can be used across processes , CCriticalSection It can only be used inside the process .
establish CMutex Need more resources , It is only used inside the process CCriticalSection Get more efficiency .
CCriticalSection m_CritSection;// For critical zone Method 1
CSingleLock singleLock(&m_CritSection); //
//CMutex Mutex;// For mutexes Method 2
//CSingleLock singleLock(&Mutex); //
int StartMainLock()
{
singleLock.Lock();// Lock yourself without being called , Have been called and wait
if (singleLock.IsLocked())
{
int ret=StartMain(); // Locked Deal with content
singleLock.Unlock();// Unlock All unlocked before returning
return ret;
}
singleLock.Unlock();// Unlock
return -1;
}
// event
HANDLE m_hEvent= CreateEvent(NULL, FALSE, FALSE, NULL); // newly build
WaitForSingleObject(m_hEvent, INFINITE); // Infinite time waiting
ResetEvent(m_hEvent); Reset For no signal
SetEvent(m_hEvent); // Set with signal
CloseHandle(m_hEvent); // close CSemaphore Specifies the count of threads for the resource
边栏推荐
- 2、 What is the principle of layer 3 and 4 switching technology? Recommended collection!
- Audio knowledge (V) -- data processing
- Accelerate large-scale data analysis based on Apache iceberg through data organization optimization
- Software performance test analysis and tuning practice path - JMeter's performance pressure test analysis and tuning of RPC Services - manuscript excerpts
- 0 foundation a literature club low code development member management applet (II)
- [image feature extraction] image feature extraction based on pulse coupled neural network (PCNN) including Matlab source code
- 【WordPress建站】6. 文章内容防复制
- 0 foundation a literature club low code development member management applet (III)
- [WordPress website] 5 Set code highlight
- What is an intrusion detection system?
猜你喜欢

bjdctf_2020_babystack

jarvisoj_level2

现货黄金有哪些眩人的小技术?

The fund management of London gold is more important than others

学会使用楼宇控制系统BACnet网关没那么难

Huawei cloud image engine service
![[WUSTCTF2020]alison_ likes_ jojo](/img/a9/dcc6f524772cd0b8781289cbaef63f.png)
[WUSTCTF2020]alison_ likes_ jojo

MFC使用控制台时 项目路径中不能有空格和中文,否则会报错误 LNK1342 未能保存要编辑的二进制文件的备份副本等

【信号识别】基于深度学习CNN实现信号调制分类附matlab代码
![[image segmentation] retinal vessel segmentation based on morphology with matlab code](/img/e3/0805df81a597346ea7c2d2da20ac96.png)
[image segmentation] retinal vessel segmentation based on morphology with matlab code
随机推荐
Vmware tools still exist after normal uninstallation for many times. How to solve it
[mrctf2020] thousand layer routine
[wustctf2020] climb
现货黄金有哪些值得借鉴的心态
Mysql---三张表(student,课程,分数) 查询课程为数学的学生姓名,编号,成绩
在终端pip install xxx但在pycharm却no module named xxx
Audio knowledge (V) -- data processing
(CVE-2020-11978)Airflow dag中的命令注入漏洞复现【vulhub靶场】
0 foundation a literature club low code development member management applet (II)
华为云数据库进阶学习
buuctf misc [UTCTF2020]docx
捏脸师: 炙手可热的元宇宙造型师
How to distinguish PAAS, IAAs and SaaS?
Summary of 2022 blue team HW elementary interview questions
[security] how to [host security - hybrid cloud version] support secure access to non Tencent virtual machines
Coding helps promote the internationalization of Tencent games
游戏思考14:对cache_server缓冲服务器的问题思考(读云峰博客有感)
[OGeek2019]babyrop
Clickhouse source code note 6: exploring the sorting of columnar storage systems
Leetcode probability interview shock series 11~15