refactor event system
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
Some checks failed
BlockStorage/repertory/pipeline/head There was a failure building this commit
This commit is contained in:
@ -31,7 +31,7 @@ class app_config;
|
|||||||
class i_provider;
|
class i_provider;
|
||||||
|
|
||||||
class fuse_base {
|
class fuse_base {
|
||||||
E_CONSUMER2();
|
E_CONSUMER();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit fuse_base(app_config &config);
|
explicit fuse_base(app_config &config);
|
||||||
|
@ -32,13 +32,13 @@ class lock_data;
|
|||||||
class server;
|
class server;
|
||||||
namespace remote_winfsp {
|
namespace remote_winfsp {
|
||||||
class remote_winfsp_drive final : public virtual FileSystemBase {
|
class remote_winfsp_drive final : public virtual FileSystemBase {
|
||||||
E_CONSUMER2();
|
E_CONSUMER();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
remote_winfsp_drive(app_config &config, remote_instance_factory factory,
|
remote_winfsp_drive(app_config &config, remote_instance_factory factory,
|
||||||
lock_data &lock);
|
lock_data &lock);
|
||||||
|
|
||||||
~remote_winfsp_drive() override { E_CONSUMER2_RELEASE(); }
|
~remote_winfsp_drive() override { E_CONSUMER_RELEASE(); }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
class winfsp_service : virtual public Service {
|
class winfsp_service : virtual public Service {
|
||||||
|
@ -37,12 +37,12 @@ class i_provider;
|
|||||||
|
|
||||||
class winfsp_drive final : public virtual i_winfsp_drive,
|
class winfsp_drive final : public virtual i_winfsp_drive,
|
||||||
public virtual FileSystemBase {
|
public virtual FileSystemBase {
|
||||||
E_CONSUMER2();
|
E_CONSUMER();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
winfsp_drive(app_config &config, lock_data &lockData, i_provider &provider);
|
winfsp_drive(app_config &config, lock_data &lockData, i_provider &provider);
|
||||||
|
|
||||||
~winfsp_drive() override { E_CONSUMER2_RELEASE(); }
|
~winfsp_drive() override { E_CONSUMER_RELEASE(); }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class winfsp_service final : virtual public Service {
|
class winfsp_service final : virtual public Service {
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
class console_consumer final {
|
class console_consumer final {
|
||||||
E_CONSUMER2();
|
E_CONSUMER();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
console_consumer();
|
console_consumer();
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
class logging_consumer final {
|
class logging_consumer final {
|
||||||
E_CONSUMER2();
|
E_CONSUMER();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
logging_consumer(event_level level, std::string log_directory);
|
logging_consumer(event_level level, std::string log_directory);
|
||||||
|
@ -121,24 +121,24 @@ public:
|
|||||||
|
|
||||||
using event_consumer = event_system::event_consumer;
|
using event_consumer = event_system::event_consumer;
|
||||||
|
|
||||||
#define E_CONSUMER2() \
|
#define E_CONSUMER() \
|
||||||
private: \
|
private: \
|
||||||
std::vector<std::shared_ptr<repertory::event_consumer>> event_consumers2_
|
std::vector<std::shared_ptr<repertory::event_consumer>> event_consumers_
|
||||||
|
|
||||||
#define E_CONSUMER2_RELEASE() event_consumers2_.clear()
|
#define E_CONSUMER_RELEASE() event_consumers_.clear()
|
||||||
|
|
||||||
#define E_SUBSCRIBE2(name, callback) \
|
#define E_SUBSCRIBE(name, callback) \
|
||||||
event_consumers2_.emplace_back(std::make_shared<repertory::event_consumer>( \
|
event_consumers_.emplace_back(std::make_shared<repertory::event_consumer>( \
|
||||||
#name, [this](const i_event &evt) { callback(evt); }))
|
#name, [this](const i_event &evt) { callback(evt); }))
|
||||||
|
|
||||||
#define E_SUBSCRIBE2_EXACT(name, callback) \
|
#define E_SUBSCRIBE_EXACT(name, callback) \
|
||||||
event_consumers2_.emplace_back(std::make_shared<repertory::event_consumer>( \
|
event_consumers_.emplace_back(std::make_shared<repertory::event_consumer>( \
|
||||||
#name, [this](const i_event &evt) { \
|
#name, [this](const i_event &evt) { \
|
||||||
callback(dynamic_cast<const name &>(evt)); \
|
callback(dynamic_cast<const name &>(evt)); \
|
||||||
}))
|
}))
|
||||||
|
|
||||||
#define E_SUBSCRIBE2_ALL(callback) \
|
#define E_SUBSCRIBE_ALL(callback) \
|
||||||
event_consumers2_.emplace_back(std::make_shared<repertory::event_consumer>( \
|
event_consumers_.emplace_back(std::make_shared<repertory::event_consumer>( \
|
||||||
[this](const i_event &evt) { callback(evt); }))
|
[this](const i_event &evt) { callback(evt); }))
|
||||||
} // namespace repertory
|
} // namespace repertory
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ class app_config;
|
|||||||
class i_provider;
|
class i_provider;
|
||||||
|
|
||||||
class file_manager final : public i_file_manager, public i_upload_manager {
|
class file_manager final : public i_file_manager, public i_upload_manager {
|
||||||
E_CONSUMER2();
|
E_CONSUMER();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr const std::chrono::seconds queue_wait_secs{
|
static constexpr const std::chrono::seconds queue_wait_secs{
|
||||||
|
@ -90,12 +90,12 @@ fuse_base::fuse_base(app_config &config) : config_(config) {
|
|||||||
fuse_ops_.flag_reserved = 0;
|
fuse_ops_.flag_reserved = 0;
|
||||||
#endif // FUSE_USE_VERSION < 30
|
#endif // FUSE_USE_VERSION < 30
|
||||||
|
|
||||||
E_SUBSCRIBE2_EXACT(unmount_requested, [this](const unmount_requested &) {
|
E_SUBSCRIBE_EXACT(unmount_requested, [this](const unmount_requested &) {
|
||||||
std::thread([this]() { this->shutdown(); }).detach();
|
std::thread([this]() { this->shutdown(); }).detach();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fuse_base::~fuse_base() { E_CONSUMER2_RELEASE(); }
|
fuse_base::~fuse_base() { E_CONSUMER_RELEASE(); }
|
||||||
|
|
||||||
auto fuse_base::access_(const char *path, int mask) -> int {
|
auto fuse_base::access_(const char *path, int mask) -> int {
|
||||||
REPERTORY_USES_FUNCTION_NAME();
|
REPERTORY_USES_FUNCTION_NAME();
|
||||||
|
@ -105,7 +105,7 @@ remote_winfsp_drive::remote_winfsp_drive(app_config &config,
|
|||||||
config_(config),
|
config_(config),
|
||||||
lock_(lock),
|
lock_(lock),
|
||||||
factory_(std::move(factory)) {
|
factory_(std::move(factory)) {
|
||||||
E_SUBSCRIBE2_EXACT(unmount_requested, [this](const unmount_requested &) {
|
E_SUBSCRIBE_EXACT(unmount_requested, [this](const unmount_requested &) {
|
||||||
std::thread([this]() { this->shutdown(); }).detach();
|
std::thread([this]() { this->shutdown(); }).detach();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ auto winfsp_drive::winfsp_service::OnStop() -> NTSTATUS {
|
|||||||
winfsp_drive::winfsp_drive(app_config &config, lock_data &lock,
|
winfsp_drive::winfsp_drive(app_config &config, lock_data &lock,
|
||||||
i_provider &provider)
|
i_provider &provider)
|
||||||
: provider_(provider), config_(config), lock_(lock) {
|
: provider_(provider), config_(config), lock_(lock) {
|
||||||
E_SUBSCRIBE2_EXACT(unmount_requested, [this](const unmount_requested &) {
|
E_SUBSCRIBE_EXACT(unmount_requested, [this](const unmount_requested &) {
|
||||||
std::thread([this]() { this->shutdown(); }).detach();
|
std::thread([this]() { this->shutdown(); }).detach();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -62,12 +62,12 @@ console_consumer::console_consumer(event_level level) {
|
|||||||
|
|
||||||
set_level(level);
|
set_level(level);
|
||||||
|
|
||||||
E_SUBSCRIBE2_ALL(process_event2);
|
E_SUBSCRIBE_ALL(process_event2);
|
||||||
E_SUBSCRIBE2_EXACT(event_level_changed,
|
E_SUBSCRIBE_EXACT(event_level_changed,
|
||||||
[](auto &&event) { set_level(event.level); });
|
[](auto &&event) { set_level(event.level); });
|
||||||
}
|
}
|
||||||
|
|
||||||
console_consumer::~console_consumer() { E_CONSUMER2_RELEASE(); }
|
console_consumer::~console_consumer() { E_CONSUMER_RELEASE(); }
|
||||||
|
|
||||||
void console_consumer::process_event2(const i_event &evt) {
|
void console_consumer::process_event2(const i_event &evt) {
|
||||||
switch (evt.get_event_level()) {
|
switch (evt.get_event_level()) {
|
||||||
|
@ -66,12 +66,12 @@ logging_consumer::logging_consumer(event_level level,
|
|||||||
|
|
||||||
set_level(level);
|
set_level(level);
|
||||||
|
|
||||||
E_SUBSCRIBE2_ALL(process_event2);
|
E_SUBSCRIBE_ALL(process_event2);
|
||||||
E_SUBSCRIBE2_EXACT(event_level_changed,
|
E_SUBSCRIBE_EXACT(event_level_changed,
|
||||||
[](auto &&event) { set_level(event.level); });
|
[](auto &&event) { set_level(event.level); });
|
||||||
}
|
}
|
||||||
|
|
||||||
logging_consumer::~logging_consumer() { E_CONSUMER2_RELEASE(); }
|
logging_consumer::~logging_consumer() { E_CONSUMER_RELEASE(); }
|
||||||
|
|
||||||
void logging_consumer::process_event2(const i_event &evt) {
|
void logging_consumer::process_event2(const i_event &evt) {
|
||||||
switch (evt.get_event_level()) {
|
switch (evt.get_event_level()) {
|
||||||
|
@ -58,7 +58,7 @@ file_manager::file_manager(app_config &config, i_provider &provider)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
E_SUBSCRIBE2_EXACT(file_upload_completed,
|
E_SUBSCRIBE_EXACT(file_upload_completed,
|
||||||
[this](auto &&event) { this->upload_completed(event); });
|
[this](auto &&event) { this->upload_completed(event); });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ file_manager::~file_manager() {
|
|||||||
stop();
|
stop();
|
||||||
mgr_db_.reset();
|
mgr_db_.reset();
|
||||||
|
|
||||||
E_CONSUMER2_RELEASE();
|
E_CONSUMER_RELEASE();
|
||||||
}
|
}
|
||||||
|
|
||||||
void file_manager::close(std::uint64_t handle) {
|
void file_manager::close(std::uint64_t handle) {
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
namespace repertory {
|
namespace repertory {
|
||||||
class event_capture final {
|
class event_capture final {
|
||||||
E_CONSUMER2();
|
E_CONSUMER();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit event_capture(
|
explicit event_capture(
|
||||||
@ -37,13 +37,13 @@ public:
|
|||||||
std::vector<std::string_view> non_fired_event_names = {})
|
std::vector<std::string_view> non_fired_event_names = {})
|
||||||
: event_names_(std::move(event_names)),
|
: event_names_(std::move(event_names)),
|
||||||
non_fired_event_names_(std::move(non_fired_event_names)) {
|
non_fired_event_names_(std::move(non_fired_event_names)) {
|
||||||
E_SUBSCRIBE2_ALL(process_event);
|
E_SUBSCRIBE_ALL(process_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
~event_capture() {
|
~event_capture() {
|
||||||
wait_for_empty();
|
wait_for_empty();
|
||||||
|
|
||||||
E_CONSUMER2_RELEASE();
|
E_CONSUMER_RELEASE();
|
||||||
|
|
||||||
EXPECT_TRUE(event_names_.empty());
|
EXPECT_TRUE(event_names_.empty());
|
||||||
for (const auto &event_name : event_names_) {
|
for (const auto &event_name : event_names_) {
|
||||||
|
Reference in New Issue
Block a user