#include <condition_variable>
#include <mutex>
+#include "build/build_config.h"
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "perfetto/base/time.h"
+#endif // BUILDFLAG(IS_TIZEN_TV)
+
namespace perfetto {
namespace base {
// Synchronously block until the event is notified.
void Wait();
+#if BUILDFLAG(IS_TIZEN_TV)
+ bool TimedWait(TimeSeconds seconds);
+#endif // BUILDFLAG(IS_TIZEN_TV)
+
// Signal the event, waking up blocked waiters.
void Notify();
return event_.wait(lock, [this] { return notified_; });
}
+#if BUILDFLAG(IS_TIZEN_TV)
+bool WaitableEvent::TimedWait(TimeSeconds seconds) {
+ std::unique_lock<std::mutex> lock(mutex_);
+ return event_.wait_for(lock, seconds, [this] { return notified_; });
+}
+#endif // BUILDFLAG(IS_TIZEN_TV)
+
void WaitableEvent::Notify() {
std::unique_lock<std::mutex> lock(mutex_);
notified_ = true;
#include <condition_variable>
#include <mutex>
+#include "build/build_config.h"
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "perfetto/base/logging.h"
+#include "perfetto/base/time.h"
+#include "perfetto/ext/base/waitable_event.h"
+#endif // BUILDFLAG(IS_TIZEN_TV)
#include "perfetto/ext/base/no_destructor.h"
#include "perfetto/ext/base/waitable_event.h"
#include "perfetto/tracing/internal/track_event_internal.h"
+#if BUILDFLAG(IS_TIZEN_TV)
+#include "src/tracing/internal/tracing_muxer_fake.h"
+#endif // BUILDFLAG(IS_TIZEN_TV)
#include "src/tracing/internal/tracing_muxer_impl.h"
namespace perfetto {
namespace {
bool g_was_initialized = false;
+#if BUILDFLAG(IS_TIZEN_TV)
+base::WaitableEvent g_initialize_event;
+#endif // BUILDFLAG(IS_TIZEN_TV)
+
// Wrapped in a function to avoid global constructor
std::mutex& InitializedMutex() {
static base::NoDestructor<std::mutex> initialized_mutex;
internal::TracingMuxerImpl::InitializeInstance(args);
internal::TrackRegistry::InitializeInstance();
g_was_initialized = true;
+#if BUILDFLAG(IS_TIZEN_TV)
+ g_initialize_event.Notify();
+#endif // BUILDFLAG(IS_TIZEN_TV)
}
// static
std::unique_ptr<TracingSession> Tracing::NewTraceInternal(
BackendType backend,
TracingConsumerBackend* (*system_backend_factory)()) {
+#if BUILDFLAG(IS_TIZEN_TV)
+ static constexpr const auto kInitializationTimeout =
+ base::TimeSeconds(10);
+ g_initialize_event.TimedWait(kInitializationTimeout);
+ PERFETTO_CHECK(internal::TracingMuxer::Get() &&
+ internal::TracingMuxer::Get() != internal::TracingMuxerFake::Get());
+#endif // BUILDFLAG(IS_TIZEN_TV)
return static_cast<internal::TracingMuxerImpl*>(internal::TracingMuxer::Get())
->CreateTracingSession(backend, system_backend_factory);
}