diff options
-rw-r--r-- | src/core/GpgFunctionObject.cpp | 24 | ||||
-rw-r--r-- | src/core/GpgFunctionObject.h | 23 | ||||
-rw-r--r-- | src/core/thread/Task.cpp | 20 | ||||
-rw-r--r-- | src/core/thread/Task.h | 7 | ||||
-rw-r--r-- | src/core/thread/TaskRunner.cpp | 14 |
5 files changed, 39 insertions, 49 deletions
diff --git a/src/core/GpgFunctionObject.cpp b/src/core/GpgFunctionObject.cpp index 9fb55247..84a3f5b7 100644 --- a/src/core/GpgFunctionObject.cpp +++ b/src/core/GpgFunctionObject.cpp @@ -51,19 +51,19 @@ void GpgFrontend::SingletonStorage::ReleaseChannel(int channel) { _it = instances_map_.find(channel); } if (_it != instances_map_.end()) instances_map_.erase(_it); - DLOG(INFO) << "channel" << channel << "released"; + DLOG(TRACE) << "channel" << channel << "released"; } GpgFrontend::ChannelObject* GpgFrontend::SingletonStorage::FindObjectInChannel( int channel) { - LOG(INFO) << "channel:" << channel << "instance address:" << &instances_map_; + LOG(TRACE) << "channel:" << channel << "instance address:" << &instances_map_; // read instances_map_ decltype(instances_map_.end()) _it; { std::shared_lock<std::shared_mutex> lock(instances_mutex_); _it = instances_map_.find(channel); if (_it == instances_map_.end()) { - LOG(INFO) << "channel:" << channel << "not found"; + LOG(TRACE) << "channel:" << channel << "not found"; return nullptr; } else { return _it->second.get(); @@ -82,8 +82,8 @@ std::vector<int> GpgFrontend::SingletonStorage::GetAllChannelId() { GpgFrontend::ChannelObject* GpgFrontend::SingletonStorage::SetObjectInChannel( int channel, std::unique_ptr<ChannelObject> p_obj) { { - LOG(INFO) << "channel:" << channel - << "instance address:" << &instances_map_; + LOG(TRACE) << "channel:" << channel + << "instance address:" << &instances_map_; assert(p_obj != nullptr); if (p_obj == nullptr) return nullptr; @@ -102,7 +102,7 @@ GpgFrontend::SingletonStorage* GpgFrontend::SingletonStorageCollection::GetSingletonStorage( const std::type_info& type_id) { const auto hash = type_id.hash_code(); - LOG(INFO) << "hash" << hash << "type_name:" << type_id.name(); + LOG(TRACE) << "hash" << hash << "type_name:" << type_id.name(); while (true) { decltype(storages_map_.end()) _it; @@ -111,16 +111,16 @@ GpgFrontend::SingletonStorageCollection::GetSingletonStorage( _it = storages_map_.find(hash); } if (_it == storages_map_.end()) { - LOG(INFO) << "hash:" << hash << "not found"; + LOG(TRACE) << "hash:" << hash << "not found"; { std::unique_lock<std::shared_mutex> lock(storages_mutex_); storages_map_.insert({hash, std::make_unique<SingletonStorage>()}); - LOG(INFO) << "hash:" << hash << "created" - << "storage address:" << &storages_map_; + LOG(TRACE) << "hash:" << hash << "created" + << "storage address:" << &storages_map_; } continue; } else { - LOG(INFO) << "hash:" << hash << "found"; + LOG(TRACE) << "hash:" << hash << "found"; return _it->second.get(); } } @@ -138,6 +138,6 @@ GpgFrontend::SingletonStorageCollection::GetInstance() { GpgFrontend::ChannelObject::ChannelObject() noexcept = default; GpgFrontend::ChannelObject::ChannelObject(int channel) : channel_(channel) { - LOG(INFO) << "called" - << "channel:" << channel; + LOG(TRACE) << "called" + << "channel:" << channel; } diff --git a/src/core/GpgFunctionObject.h b/src/core/GpgFunctionObject.h index f16e4cae..7d82ec89 100644 --- a/src/core/GpgFunctionObject.h +++ b/src/core/GpgFunctionObject.h @@ -29,18 +29,7 @@ #ifndef GPGFRONTEND_ZH_CN_TS_FUNCTIONOBJECT_H #define GPGFRONTEND_ZH_CN_TS_FUNCTIONOBJECT_H -#include <map> -#include <memory> -#include <mutex> -#include <shared_mutex> -#include <stdexcept> -#include <string> -#include <typeinfo> -#include <utility> -#include <vector> - #include "GpgConstants.h" -#include "easylogging++.h" namespace GpgFrontend { @@ -189,14 +178,14 @@ class SingletonFunctionObject : public ChannelObject { auto* _p_pbj = (T*)(p_storage->FindObjectInChannel(channel)); - LOG(INFO) << "object address" << _p_pbj; - if (_p_pbj == nullptr) { auto new_obj = std::unique_ptr<ChannelObject>(new T(channel)); - LOG(INFO) << "create new object"; + LOG(TRACE) << "create new object" << new_obj.get(); return *(T*)(p_storage->SetObjectInChannel(channel, std::move(new_obj))); - } else + } else { + LOG(TRACE) << "saved object address" << _p_pbj; return *_p_pbj; + } } /** @@ -293,8 +282,8 @@ class SingletonFunctionObject : public ChannelObject { * @param channel */ explicit SingletonFunctionObject(int channel) : ChannelObject(channel) { - LOG(INFO) << "called" - << "channel:" << channel; + LOG(TRACE) << "called" + << "channel:" << channel; } /** diff --git a/src/core/thread/Task.cpp b/src/core/thread/Task.cpp index 7b8423b2..1f24b42e 100644 --- a/src/core/thread/Task.cpp +++ b/src/core/thread/Task.cpp @@ -37,7 +37,7 @@ #include "easylogging++.h" GpgFrontend::Thread::Task::Task() : uuid_(generate_uuid()) { - LOG(INFO) << "Task" << uuid_ << "created"; + LOG(TRACE) << "Task" << uuid_ << "created"; init(); } @@ -47,8 +47,8 @@ GpgFrontend::Thread::Task::Task(TaskCallback callback, callback_(std::move(callback)), callback_thread_(QThread::currentThread()), data_object_(data_object) { - LOG(INFO) << "Task" << uuid_ << "created with callback" - << "callback_thread_: " << callback_thread_; + LOG(TRACE) << "Task" << uuid_ << "created with callback" + << "callback_thread_: " << callback_thread_; init(); } @@ -60,8 +60,8 @@ GpgFrontend::Thread::Task::Task(TaskRunnable runnable, TaskCallback callback, callback_thread_(QThread::currentThread()), data_object_(data_object) { init(); - LOG(INFO) << "Task" << uuid_ << "created with runnable and callback" - << "callback_thread_: " << callback_thread_; + LOG(TRACE) << "Task" << uuid_ << "created with runnable and callback" + << "callback_thread_: " << callback_thread_; } GpgFrontend::Thread::Task::~Task() = default; @@ -80,7 +80,7 @@ void GpgFrontend::Thread::Task::init() { } void GpgFrontend::Thread::Task::before_finish_task() { - LOG(INFO) << "Task" << uuid_ << "finished"; + LOG(TRACE) << "Task" << uuid_ << "finished"; if (callback_) { bool if_invoke = QMetaObject::invokeMethod( callback_thread_, @@ -94,7 +94,7 @@ void GpgFrontend::Thread::Task::before_finish_task() { } void GpgFrontend::Thread::Task::run() { - LOG(INFO) << "Task" << uuid_ << "started"; + LOG(TRACE) << "Task" << uuid_ << "started"; Run(); if (finish_after_run_) emit SignalTaskFinished(); } @@ -104,7 +104,7 @@ void GpgFrontend::Thread::Task::Run() { bool if_invoke = QMetaObject::invokeMethod( this, [=]() { return runnable_(data_object_); }, &rtn_); if (!if_invoke) { - LOG(ERROR) << "invokeMethod failed"; + LOG(ERROR) << "Qt invokeMethod failed"; } } } @@ -131,8 +131,8 @@ size_t GpgFrontend::Thread::Task::DataObject::GetObjectSize() { } void GpgFrontend::Thread::Task::DataObject::free_heap_ptr(Destructor *ptr) { - LOG(INFO) << "p_obj: " << ptr->p_obj << "destructor: " << ptr->destroy - << "DataObject:" << this; + DLOG(TRACE) << "p_obj: " << ptr->p_obj << "destructor: " << ptr->destroy + << "DataObject:" << this; if (ptr->destroy != nullptr) { ptr->destroy(ptr->p_obj); } diff --git a/src/core/thread/Task.h b/src/core/thread/Task.h index 468a04b8..9f6d8669 100644 --- a/src/core/thread/Task.h +++ b/src/core/thread/Task.h @@ -78,7 +78,7 @@ class GPGFRONTEND_CORE_EXPORT Task : public QObject, public QRunnable { */ template <typename T> void AppendObject(T &&obj) { - LOG(INFO) << "called:" << this; + DLOG(TRACE) << "called:" << this; auto *obj_dstr = this->get_heap_ptr(sizeof(T)); auto *ptr_heap = new ((void *)obj_dstr->p_obj) T(std::move(obj)); if (std::is_class_v<T>) { @@ -100,10 +100,11 @@ class GPGFRONTEND_CORE_EXPORT Task : public QObject, public QRunnable { */ template <typename T> void AppendObject(T *obj) { - LOG(INFO) << "called:" << this; + DLOG(TRACE) << "called:" << this; auto *obj_dstr = this->get_heap_ptr(sizeof(T)); auto *ptr_heap = new ((void *)obj_dstr->p_obj) T(std::move(*obj)); if (std::is_class_v<T>) { + LOG(TRACE) << "is class"; auto destructor = [](const void *x) { static_cast<const T *>(x)->~T(); }; @@ -122,7 +123,7 @@ class GPGFRONTEND_CORE_EXPORT Task : public QObject, public QRunnable { */ template <typename T> T PopObject() { - LOG(INFO) << "called:" << this; + DLOG(TRACE) << "called:" << this; if (data_objects_.empty()) throw std::runtime_error("No object to pop"); auto *obj_dstr = data_objects_.top(); auto *heap_ptr = (T *)obj_dstr->p_obj; diff --git a/src/core/thread/TaskRunner.cpp b/src/core/thread/TaskRunner.cpp index 3b565abb..226aec0e 100644 --- a/src/core/thread/TaskRunner.cpp +++ b/src/core/thread/TaskRunner.cpp @@ -36,8 +36,8 @@ GpgFrontend::Thread::TaskRunner::TaskRunner() = default; GpgFrontend::Thread::TaskRunner::~TaskRunner() = default; void GpgFrontend::Thread::TaskRunner::PostTask(Task* task) { - LOG(INFO) << "called" - << "Post Task" << task->GetUUID(); + LOG(TRACE) << "called" + << "Post Task" << task->GetUUID(); if (task == nullptr) return; task->setParent(nullptr); @@ -50,14 +50,14 @@ void GpgFrontend::Thread::TaskRunner::PostTask(Task* task) { } void GpgFrontend::Thread::TaskRunner::run() { - LOG(INFO) << "called" - << "thread id:" << QThread::currentThreadId(); + LOG(TRACE) << "called" + << "thread id:" << QThread::currentThreadId(); while (true) { if (tasks.empty()) { - LOG(INFO) << "TaskRunner: No tasks to run."; + LOG(TRACE) << "TaskRunner: No tasks to run."; exec(); } else { - LOG(INFO) << "TaskRunner: Queue size:" << tasks.size(); + LOG(TRACE) << "TaskRunner: Queue size:" << tasks.size(); Task* task = nullptr; { @@ -68,7 +68,7 @@ void GpgFrontend::Thread::TaskRunner::run() { if (task != nullptr) { // Run the task - LOG(INFO) << "TaskRunner: Running Task" << task->GetUUID(); + LOG(TRACE) << "TaskRunner: Running Task" << task->GetUUID(); try { task->run(); } catch (const std::exception& e) { |