Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Unified Diff: webrtc/call/rtc_event_log_helper_thread.h

Issue 2035483003: Hibernate the thread if there are no events in the queue. Wake it up when an event is added to the … (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rename SignalStopFile() -> WaitForFileFinished() Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/call/rtc_event_log_helper_thread.h
diff --git a/webrtc/call/rtc_event_log_helper_thread.h b/webrtc/call/rtc_event_log_helper_thread.h
index 60ed912b65163a22971272c8b9ab05cd4fcc5e89..2d5a78586dae0f02e7c29315dd11ae35c7d685a7 100644
--- a/webrtc/call/rtc_event_log_helper_thread.h
+++ b/webrtc/call/rtc_event_log_helper_thread.h
@@ -67,22 +67,27 @@ class RtcEventLogHelperThread final {
RtcEventLogHelperThread(
SwapQueue<ControlMessage>* message_queue,
SwapQueue<std::unique_ptr<rtclog::Event>>* event_queue,
- rtc::Event* wake_up,
- rtc::Event* file_finished,
const Clock* const clock);
~RtcEventLogHelperThread();
+ // This function MUST be called once a STOP_FILE message is added to the
+ // signalling queue. The function will make sure that the output thread
+ // wakes up to read the message, and it blocks until the output thread has
+ // finished writing to the file.
+ void WaitForFileFinished();
+
+ // This fuction MUST be called once an event is added to the event queue.
+ void SignalNewEvent();
+
private:
static bool ThreadOutputFunction(void* obj);
- void TerminateThread();
bool AppendEventToString(rtclog::Event* event);
- void AppendEventToHistory(const rtclog::Event& event);
- void LogToMemory();
+ bool LogToMemory();
void StartLogFile();
- void LogToFile();
+ bool LogToFile();
void StopLogFile();
- void WriteLog();
+ void ProcessEvents();
// Message queues for passing events to the logging thread.
SwapQueue<ControlMessage>* message_queue_;
@@ -108,8 +113,9 @@ class RtcEventLogHelperThread final {
// Temporary space for serializing profobuf data.
std::string output_string_;
- rtc::Event* wake_up_;
- rtc::Event* stopped_;
+ rtc::Event wake_periodically_;
+ rtc::Event wake_from_hibernation_;
+ rtc::Event file_finished_;
const Clock* const clock_;

Powered by Google App Engine
This is Rietveld 408576698