mirror of
https://github.com/Artikash/Textractor.git
synced 2024-12-24 01:14:12 +08:00
minor fixes
This commit is contained in:
parent
a290c36b52
commit
9dfebf7eac
@ -18,6 +18,8 @@ set(vnrhost_src
|
|||||||
textthread.cc
|
textthread.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
include_directories(../)
|
||||||
|
|
||||||
add_library(vnrhost SHARED ${vnrhost_src})
|
add_library(vnrhost SHARED ${vnrhost_src})
|
||||||
|
|
||||||
set_target_properties(vnrhost PROPERTIES LINK_FLAGS /SUBSYSTEM:WINDOWS)
|
set_target_properties(vnrhost PROPERTIES LINK_FLAGS /SUBSYSTEM:WINDOWS)
|
||||||
|
@ -8,26 +8,28 @@
|
|||||||
# pragma warning(disable:4800) // C4800: forcing value to bool
|
# pragma warning(disable:4800) // C4800: forcing value to bool
|
||||||
#endif // _MSC_VER
|
#endif // _MSC_VER
|
||||||
|
|
||||||
class MutexLocker
|
// Artikash 7/20/2018: these are similar to std::lock guard but use Winapi objects
|
||||||
{
|
|
||||||
|
class MutexLocker
|
||||||
|
{
|
||||||
HANDLE m;
|
HANDLE m;
|
||||||
public:
|
public:
|
||||||
explicit MutexLocker(HANDLE mutex) : m(mutex)
|
explicit MutexLocker(HANDLE mutex) : m(mutex)
|
||||||
{
|
{
|
||||||
WaitForSingleObject(m, 0);
|
WaitForSingleObject(m, 0);
|
||||||
}
|
}
|
||||||
~MutexLocker() { if (m != INVALID_HANDLE_VALUE && m != nullptr) ReleaseMutex(m); }
|
~MutexLocker() { if (m != INVALID_HANDLE_VALUE && m != nullptr) ReleaseMutex(m); }
|
||||||
};
|
};
|
||||||
|
|
||||||
class CriticalSectionLocker
|
class CriticalSectionLocker
|
||||||
{
|
{
|
||||||
CRITICAL_SECTION cs;
|
CRITICAL_SECTION cs;
|
||||||
public:
|
public:
|
||||||
explicit CriticalSectionLocker(CRITICAL_SECTION cs) : cs(cs)
|
explicit CriticalSectionLocker(CRITICAL_SECTION cs) : cs(cs)
|
||||||
{
|
{
|
||||||
EnterCriticalSection(&cs);
|
EnterCriticalSection(&cs);
|
||||||
}
|
}
|
||||||
~CriticalSectionLocker() { LeaveCriticalSection(&cs); }
|
~CriticalSectionLocker() { LeaveCriticalSection(&cs); }
|
||||||
};
|
};
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
|
Loading…
x
Reference in New Issue
Block a user