mirror of
https://github.com/notepad-plus-plus/notepad-plus-plus.git
synced 2025-07-25 23:05:13 +02:00
Remove ATL (part two)
Use std::lock_guard instead of CComCritSecLock<CComAutoCriticalSection> Close #4320
This commit is contained in:
parent
ec5fa6d2c4
commit
3439071c3c
@ -26,6 +26,7 @@
|
|||||||
// http://qualapps.blogspot.com/2010/05/understanding-readdirectorychangesw.html
|
// http://qualapps.blogspot.com/2010/05/understanding-readdirectorychangesw.html
|
||||||
// See ReadMe.txt for overview information.
|
// See ReadMe.txt for overview information.
|
||||||
|
|
||||||
|
#include <process.h>
|
||||||
#include "ReadDirectoryChanges.h"
|
#include "ReadDirectoryChanges.h"
|
||||||
#include "ReadDirectoryChangesPrivate.h"
|
#include "ReadDirectoryChangesPrivate.h"
|
||||||
|
|
||||||
|
@ -40,11 +40,6 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
#define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
|
|
||||||
|
|
||||||
#include <atlbase.h>
|
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
// http://qualapps.blogspot.com/2010/05/understanding-readdirectorychangesw.html
|
// http://qualapps.blogspot.com/2010/05/understanding-readdirectorychangesw.html
|
||||||
// See ReadMe.txt for overview information.
|
// See ReadMe.txt for overview information.
|
||||||
|
|
||||||
|
#include <shlwapi.h>
|
||||||
#include "ReadDirectoryChanges.h"
|
#include "ReadDirectoryChanges.h"
|
||||||
#include "ReadDirectoryChangesPrivate.h"
|
#include "ReadDirectoryChangesPrivate.h"
|
||||||
|
|
||||||
@ -152,7 +153,7 @@ void CReadChangesRequest::ProcessNotification()
|
|||||||
wstrFilename = m_wstrDirectory + wstrFilename;
|
wstrFilename = m_wstrDirectory + wstrFilename;
|
||||||
|
|
||||||
// If it could be a short filename, expand it.
|
// If it could be a short filename, expand it.
|
||||||
LPCWSTR wszFilename = PathFindFileNameW(wstrFilename.c_str());
|
LPCWSTR wszFilename = ::PathFindFileNameW(wstrFilename.c_str());
|
||||||
int len = lstrlenW(wszFilename);
|
int len = lstrlenW(wszFilename);
|
||||||
// The maximum length of an 8.3 filename is twelve, including the dot.
|
// The maximum length of an 8.3 filename is twelve, including the dot.
|
||||||
if (len <= 12 && wcschr(wszFilename, L'~'))
|
if (len <= 12 && wcschr(wszFilename, L'~'))
|
||||||
|
@ -26,7 +26,10 @@
|
|||||||
// http://qualapps.blogspot.com/2010/05/understanding-readdirectorychangesw.html
|
// http://qualapps.blogspot.com/2010/05/understanding-readdirectorychangesw.html
|
||||||
// See ReadMe.txt for overview information.
|
// See ReadMe.txt for overview information.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
template <typename C>
|
template <typename C>
|
||||||
class CThreadSafeQueue : protected std::list<C>
|
class CThreadSafeQueue : protected std::list<C>
|
||||||
@ -53,7 +56,7 @@ public:
|
|||||||
void push(C& c)
|
void push(C& c)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
CComCritSecLock<CComAutoCriticalSection> lock(m_Crit, true);
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
Base::push_back(c);
|
Base::push_back(c);
|
||||||
}
|
}
|
||||||
::SetEvent(m_hEvent);
|
::SetEvent(m_hEvent);
|
||||||
@ -61,7 +64,7 @@ public:
|
|||||||
|
|
||||||
bool pop(C& c)
|
bool pop(C& c)
|
||||||
{
|
{
|
||||||
CComCritSecLock<CComAutoCriticalSection> lock( m_Crit, true );
|
std::lock_guard<std::mutex> lock(m_mutex);
|
||||||
if (Base::empty())
|
if (Base::empty())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -77,6 +80,5 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
HANDLE m_hEvent;
|
HANDLE m_hEvent;
|
||||||
|
std::mutex m_mutex;
|
||||||
CComAutoCriticalSection m_Crit;
|
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user