264 lines
9.2 KiB
Diff
264 lines
9.2 KiB
Diff
diff --git a/frameworks/eventhandler/BUILD.gn b/frameworks/eventhandler/BUILD.gn
|
|
index ceed950..7342337 100644
|
|
--- a/frameworks/eventhandler/BUILD.gn
|
|
+++ b/frameworks/eventhandler/BUILD.gn
|
|
@@ -37,7 +37,7 @@ ohos_shared_library("libeventhandler") {
|
|
public_configs = [ ":public_libeventhandler_config" ]
|
|
|
|
external_deps = [
|
|
- "hitrace_native:libhitracechain",
|
|
+ # "hitrace_native:libhitracechain",
|
|
"hiviewdfx_hilog_native:libhilog",
|
|
]
|
|
|
|
diff --git a/frameworks/eventhandler/include/event_handler_utils.h b/frameworks/eventhandler/include/event_handler_utils.h
|
|
index 72fbdac..37e862f 100644
|
|
--- a/frameworks/eventhandler/include/event_handler_utils.h
|
|
+++ b/frameworks/eventhandler/include/event_handler_utils.h
|
|
@@ -22,7 +22,7 @@
|
|
#include <string>
|
|
|
|
#include "hilog/log.h"
|
|
-#include "hitrace/trace.h"
|
|
+// #include "hitrace/trace.h"
|
|
#include "inner_event.h"
|
|
|
|
#define DEFINE_HILOG_LABEL(name) \
|
|
@@ -66,30 +66,30 @@ static inline int32_t NanosecondsToTimeout(int64_t nanoseconds)
|
|
return (milliseconds > INT32_MAX) ? INT32_MAX : static_cast<int32_t>(milliseconds);
|
|
}
|
|
|
|
-using HiTraceChain = OHOS::HiviewDFX::HiTraceChain;
|
|
+// using HiTraceChain = OHOS::HiviewDFX::HiTraceChain;
|
|
|
|
static inline bool AllowHiTraceOutPut(const std::shared_ptr<HiTraceId>& traceId, bool isSyncEvent)
|
|
{
|
|
- if ((!traceId) || (!traceId->IsValid())) {
|
|
- return false;
|
|
- }
|
|
- if ((!isSyncEvent) && (!traceId->IsFlagEnabled(HITRACE_FLAG_INCLUDE_ASYNC))) {
|
|
- return false;
|
|
- }
|
|
+ // if ((!traceId) || (!traceId->IsValid())) {
|
|
+ // return false;
|
|
+ // }
|
|
+ // if ((!isSyncEvent) && (!traceId->IsFlagEnabled(HITRACE_FLAG_INCLUDE_ASYNC))) {
|
|
+ // return false;
|
|
+ // }
|
|
return true;
|
|
}
|
|
|
|
-static inline void HiTracePointerOutPut(const std::shared_ptr<HiTraceId>& spanId,
|
|
- const InnerEvent::Pointer& event, const char* action, HiTraceTracepointType type)
|
|
-{
|
|
- if (!event->HasTask()) {
|
|
- HiTraceChain::Tracepoint(type, *spanId, "%s event, event id: %d", action, event->GetInnerEventId());
|
|
- } else if (!event->GetTaskName().empty()) {
|
|
- HiTraceChain::Tracepoint(type, *spanId, "%s task with name, name: %s", action, event->GetTaskName().c_str());
|
|
- } else {
|
|
- HiTraceChain::Tracepoint(type, *spanId, "%s UnNamed Task", action);
|
|
- }
|
|
-}
|
|
+// static inline void HiTracePointerOutPut(const std::shared_ptr<HiTraceId>& spanId,
|
|
+// const InnerEvent::Pointer& event, const char* action, HiTraceTracepointType type)
|
|
+// {
|
|
+// if (!event->HasTask()) {
|
|
+// HiTraceChain::Tracepoint(type, *spanId, "%s event, event id: %d", action, event->GetInnerEventId());
|
|
+// } else if (!event->GetTaskName().empty()) {
|
|
+// HiTraceChain::Tracepoint(type, *spanId, "%s task with name, name: %s", action, event->GetTaskName().c_str());
|
|
+// } else {
|
|
+// HiTraceChain::Tracepoint(type, *spanId, "%s UnNamed Task", action);
|
|
+// }
|
|
+// }
|
|
|
|
static inline void GetLastErr(char *errmsg, size_t size = MAX_ERRORMSG_LEN)
|
|
{
|
|
diff --git a/frameworks/eventhandler/src/event_handler.cpp b/frameworks/eventhandler/src/event_handler.cpp
|
|
index ab6e876..8477424 100644
|
|
--- a/frameworks/eventhandler/src/event_handler.cpp
|
|
+++ b/frameworks/eventhandler/src/event_handler.cpp
|
|
@@ -74,11 +74,11 @@ bool EventHandler::SendEvent(InnerEvent::Pointer &event, int64_t delayTime, Prio
|
|
|
|
event->SetOwner(shared_from_this());
|
|
// get traceId from event, if HiTraceChain::begin has been called, would get a valid trace id.
|
|
- auto traceId = event->GetOrCreateTraceId();
|
|
+ // auto traceId = event->GetOrCreateTraceId();
|
|
// if traceId is valid, out put trace information
|
|
- if (AllowHiTraceOutPut(traceId, event->HasWaiter())) {
|
|
- HiTracePointerOutPut(traceId, event, "Send", HiTraceTracepointType::HITRACE_TP_CS);
|
|
- }
|
|
+ // if (AllowHiTraceOutPut(traceId, event->HasWaiter())) {
|
|
+ // HiTracePointerOutPut(traceId, event, "Send", HiTraceTracepointType::HITRACE_TP_CS);
|
|
+ // }
|
|
|
|
eventRunner_->GetEventQueue()->Insert(event, priority);
|
|
return true;
|
|
@@ -117,7 +117,7 @@ bool EventHandler::SendSyncEvent(InnerEvent::Pointer &event, Priority priority)
|
|
}
|
|
|
|
// get traceId from event, if HiTraceChain::begin has been called, would get a valid trace id.
|
|
- auto spanId = event->GetOrCreateTraceId();
|
|
+ // auto spanId = event->GetOrCreateTraceId();
|
|
|
|
// Create waiter, used to block.
|
|
auto waiter = event->CreateWaiter();
|
|
@@ -128,9 +128,9 @@ bool EventHandler::SendSyncEvent(InnerEvent::Pointer &event, Priority priority)
|
|
// Wait until event is processed(recycled).
|
|
waiter->Wait();
|
|
|
|
- if ((spanId) && (spanId->IsValid())) {
|
|
- HiTraceChain::Tracepoint(HiTraceTracepointType::HITRACE_TP_CR, *spanId, "event is processed");
|
|
- }
|
|
+ // if ((spanId) && (spanId->IsValid())) {
|
|
+ // HiTraceChain::Tracepoint(HiTraceTracepointType::HITRACE_TP_CR, *spanId, "event is processed");
|
|
+ // }
|
|
|
|
return true;
|
|
}
|
|
@@ -305,13 +305,13 @@ void EventHandler::DistributeEvent(const InnerEvent::Pointer &event)
|
|
|
|
currentEventHandler = shared_from_this();
|
|
|
|
- auto spanId = event->GetTraceId();
|
|
- auto traceId = HiTraceChain::GetId();
|
|
- bool allowTraceOutPut = AllowHiTraceOutPut(spanId, event->HasWaiter());
|
|
- if (allowTraceOutPut) {
|
|
- HiTraceChain::SetId(*spanId);
|
|
- HiTracePointerOutPut(spanId, event, "Receive", HiTraceTracepointType::HITRACE_TP_SR);
|
|
- }
|
|
+ // auto spanId = event->GetTraceId();
|
|
+ // auto traceId = HiTraceChain::GetId();
|
|
+ // bool allowTraceOutPut = AllowHiTraceOutPut(spanId, event->HasWaiter());
|
|
+ // if (allowTraceOutPut) {
|
|
+ // HiTraceChain::SetId(*spanId);
|
|
+ // HiTracePointerOutPut(spanId, event, "Receive", HiTraceTracepointType::HITRACE_TP_SR);
|
|
+ // }
|
|
|
|
InnerEvent::TimePoint nowStart = InnerEvent::Clock::now();
|
|
DeliveryTimeAction(event, nowStart);
|
|
@@ -326,13 +326,13 @@ void EventHandler::DistributeEvent(const InnerEvent::Pointer &event)
|
|
|
|
DistributeTimeAction(event, nowStart);
|
|
|
|
- if (allowTraceOutPut) {
|
|
- HiTraceChain::Tracepoint(HiTraceTracepointType::HITRACE_TP_SS, *spanId, "Event Distribute over");
|
|
- HiTraceChain::ClearId();
|
|
- if (traceId.IsValid()) {
|
|
- HiTraceChain::SetId(traceId);
|
|
- }
|
|
- }
|
|
+ // if (allowTraceOutPut) {
|
|
+ // HiTraceChain::Tracepoint(HiTraceTracepointType::HITRACE_TP_SS, *spanId, "Event Distribute over");
|
|
+ // HiTraceChain::ClearId();
|
|
+ // if (traceId.IsValid()) {
|
|
+ // HiTraceChain::SetId(traceId);
|
|
+ // }
|
|
+ // }
|
|
}
|
|
|
|
void EventHandler::Dump(Dumper &dumper)
|
|
diff --git a/frameworks/eventhandler/src/inner_event.cpp b/frameworks/eventhandler/src/inner_event.cpp
|
|
index 654b44e..90e0c49 100644
|
|
--- a/frameworks/eventhandler/src/inner_event.cpp
|
|
+++ b/frameworks/eventhandler/src/inner_event.cpp
|
|
@@ -209,9 +209,9 @@ void InnerEvent::ClearEvent()
|
|
}
|
|
}
|
|
|
|
- if (hiTraceId_) {
|
|
- hiTraceId_.reset();
|
|
- }
|
|
+ // if (hiTraceId_) {
|
|
+ // hiTraceId_.reset();
|
|
+ // }
|
|
|
|
// Clear owner
|
|
owner_.reset();
|
|
@@ -233,25 +233,25 @@ bool InnerEvent::HasWaiter() const
|
|
return (waiter_ != nullptr);
|
|
}
|
|
|
|
-const std::shared_ptr<HiTraceId> InnerEvent::GetOrCreateTraceId()
|
|
-{
|
|
- if (hiTraceId_) {
|
|
- return hiTraceId_;
|
|
- }
|
|
-
|
|
- auto traceId = HiTraceChain::GetId();
|
|
- if (!traceId.IsValid()) {
|
|
- return nullptr;
|
|
- }
|
|
-
|
|
- hiTraceId_ = std::make_shared<HiTraceId>(HiTraceChain::CreateSpan());
|
|
- return hiTraceId_;
|
|
-}
|
|
-
|
|
-const std::shared_ptr<HiTraceId> InnerEvent::GetTraceId()
|
|
-{
|
|
- return hiTraceId_;
|
|
-}
|
|
+// const std::shared_ptr<HiTraceId> InnerEvent::GetOrCreateTraceId()
|
|
+// {
|
|
+ // if (hiTraceId_) {
|
|
+ // return hiTraceId_;
|
|
+ // }
|
|
+
|
|
+ // auto traceId = HiTraceChain::GetId();
|
|
+ // if (!traceId.IsValid()) {
|
|
+ // return nullptr;
|
|
+ // }
|
|
+
|
|
+ // hiTraceId_ = std::make_shared<HiTraceId>(HiTraceChain::CreateSpan());
|
|
+ // return hiTraceId_;
|
|
+// }
|
|
+
|
|
+// const std::shared_ptr<HiTraceId> InnerEvent::GetTraceId()
|
|
+// {
|
|
+// // return hiTraceId_;
|
|
+// }
|
|
|
|
std::string InnerEvent::Dump()
|
|
{
|
|
diff --git a/interfaces/inner_api/event_queue.h b/interfaces/inner_api/event_queue.h
|
|
index 1b4d82c..e98500d 100644
|
|
--- a/interfaces/inner_api/event_queue.h
|
|
+++ b/interfaces/inner_api/event_queue.h
|
|
@@ -20,6 +20,7 @@
|
|
#include <list>
|
|
#include <map>
|
|
#include <mutex>
|
|
+#include <atomic>
|
|
|
|
#include "inner_event.h"
|
|
#include "event_handler_errors.h"
|
|
diff --git a/interfaces/inner_api/inner_event.h b/interfaces/inner_api/inner_event.h
|
|
index b8fb32c..1bedc46 100644
|
|
--- a/interfaces/inner_api/inner_event.h
|
|
+++ b/interfaces/inner_api/inner_event.h
|
|
@@ -437,14 +437,14 @@ private:
|
|
*
|
|
* @return return hiTrace Id.
|
|
*/
|
|
- const std::shared_ptr<HiTraceId> GetOrCreateTraceId();
|
|
+ // const std::shared_ptr<HiTraceId> GetOrCreateTraceId();
|
|
|
|
/**
|
|
* return trace id.
|
|
*
|
|
* @return return hiTrace Id.
|
|
*/
|
|
- const std::shared_ptr<HiTraceId> GetTraceId();
|
|
+ // const std::shared_ptr<HiTraceId> GetTraceId();
|
|
|
|
/*
|
|
* Calculate the type id for different smart pointers.
|
|
@@ -522,7 +522,7 @@ private:
|
|
std::shared_ptr<Waiter> waiter_;
|
|
|
|
// use to store hitrace Id
|
|
- std::shared_ptr<HiTraceId> hiTraceId_;
|
|
+ // std::shared_ptr<HiTraceId> hiTraceId_;
|
|
};
|
|
} // namespace AppExecFwk
|
|
} // namespace OHOS
|