Fix builds and warnings in builds.

This commit is contained in:
Martín Lucas Golini
2026-08-21 10:51:20 -03:00
parent 864b2a9b3f
commit 2895d771ab
4 changed files with 53 additions and 40 deletions
+1 -31
View File
@@ -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