mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-01 18:50:16 +03:00
Fix builds and warnings in builds.
This commit is contained in:
@@ -2,10 +2,10 @@
|
||||
#define ECODE_FILESYSTEMLISTENER_HPP
|
||||
|
||||
#include "boundedeventqueue.hpp"
|
||||
#include "filesystemlistenercallbackstate.hpp"
|
||||
#include "filesystemlisteneroptions.hpp"
|
||||
#include "projectdirectorytree.hpp"
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <eepp/system/fileinfo.hpp>
|
||||
#include <eepp/ui/models/filesystemmodel.hpp>
|
||||
#include <eepp/ui/tools/uicodeeditorsplitter.hpp>
|
||||
@@ -20,36 +20,6 @@ using namespace EE::UI::Tools;
|
||||
|
||||
namespace ecode {
|
||||
|
||||
class FileSystemListenerCallbackState {
|
||||
public:
|
||||
bool beginCallback() {
|
||||
std::lock_guard<std::mutex> lock( mMutex );
|
||||
if ( mRemoved )
|
||||
return false;
|
||||
++mActiveCallbacks;
|
||||
return true;
|
||||
}
|
||||
|
||||
void endCallback() {
|
||||
std::lock_guard<std::mutex> lock( mMutex );
|
||||
if ( --mActiveCallbacks == 0 )
|
||||
mCondition.notify_all();
|
||||
}
|
||||
|
||||
void removeAndWait( bool calledFromThisListener ) {
|
||||
std::unique_lock<std::mutex> lock( mMutex );
|
||||
mRemoved = true;
|
||||
if ( !calledFromThisListener )
|
||||
mCondition.wait( lock, [this] { return mActiveCallbacks == 0; } );
|
||||
}
|
||||
|
||||
private:
|
||||
std::mutex mMutex;
|
||||
std::condition_variable mCondition;
|
||||
std::size_t mActiveCallbacks{ 0 };
|
||||
bool mRemoved{ false };
|
||||
};
|
||||
|
||||
class FileSystemListener : public efsw::FileWatchListener {
|
||||
public:
|
||||
typedef std::function<void( const FileEvent&, const FileInfo& )> FileEventFn;
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
#ifndef ECODE_FILESYSTEMLISTENERCALLBACKSTATE_HPP
|
||||
#define ECODE_FILESYSTEMLISTENERCALLBACKSTATE_HPP
|
||||
|
||||
#include <condition_variable>
|
||||
#include <cstddef>
|
||||
#include <mutex>
|
||||
|
||||
namespace ecode {
|
||||
|
||||
class FileSystemListenerCallbackState {
|
||||
public:
|
||||
bool beginCallback() {
|
||||
std::lock_guard<std::mutex> lock( mMutex );
|
||||
if ( mRemoved )
|
||||
return false;
|
||||
++mActiveCallbacks;
|
||||
return true;
|
||||
}
|
||||
|
||||
void endCallback() {
|
||||
std::lock_guard<std::mutex> lock( mMutex );
|
||||
if ( --mActiveCallbacks == 0 )
|
||||
mCondition.notify_all();
|
||||
}
|
||||
|
||||
void removeAndWait( bool calledFromThisListener ) {
|
||||
std::unique_lock<std::mutex> lock( mMutex );
|
||||
mRemoved = true;
|
||||
if ( !calledFromThisListener )
|
||||
mCondition.wait( lock, [this] { return mActiveCallbacks == 0; } );
|
||||
}
|
||||
|
||||
private:
|
||||
std::mutex mMutex;
|
||||
std::condition_variable mCondition;
|
||||
std::size_t mActiveCallbacks{ 0 };
|
||||
bool mRemoved{ false };
|
||||
};
|
||||
|
||||
} // namespace ecode
|
||||
|
||||
#endif // ECODE_FILESYSTEMLISTENERCALLBACKSTATE_HPP
|
||||
Reference in New Issue
Block a user