SourceXtractorPlusPlus  0.10
Please provide a description of the project.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
SourceXtractor::ProgressNCurses::Dashboard Class Reference
Collaboration diagram for SourceXtractor::ProgressNCurses::Dashboard:
[legend]

Public Member Functions

 Dashboard ()
 
 ~Dashboard ()
 
void update (const std::list< ProgressInfo > &info)
 

Private Member Functions

void uiThread ()
 
void ncursesMode ()
 

Private Attributes

std::unique_ptr< boost::thread > m_ui_thread
 
std::list< ProgressInfom_progress_info
 
std::mutex m_progress_info_mutex
 
int m_stderr_original
 
int m_stderr_pipe
 
FILEm_stderr
 
int m_stdout_original
 
int m_stdout_pipe
 
std::vector< std::stringm_log_text
 
std::atomic_bool m_trigger_resize
 

Detailed Description

The Dashboard wraps the UI screen, which runs on an independent thread to avoid race conditions.

ncurses calls are not thread safe, so it is better to contain them within a single thread. Normally, ncurses does a proper setup of signal handling (i.e. SIGINT), so the terminal is returned into its proper state. However, we want to re-print the output after exiting the curses mode, so we need to handle the signals ourselves: catch, exit ncurses, dump log, and delegate to the previously installed handler.

See Also
handleTerminatingSignal

Definition at line 673 of file ProgressNCurses.cpp.

Constructor & Destructor Documentation

SourceXtractor::ProgressNCurses::Dashboard::Dashboard ( )
inline

Constructor

Note
Intercepts stdout and stderr and starts up the UI thread

Definition at line 815 of file ProgressNCurses.cpp.

References std::bind(), std::generic_category(), SourceXtractor::interceptFileDescriptor(), m_stderr, m_stderr_original, m_stderr_pipe, m_stdout_original, m_stdout_pipe, m_ui_thread, and uiThread().

Here is the call graph for this function:

SourceXtractor::ProgressNCurses::Dashboard::~Dashboard ( )
inline

Destructor Notifies the UI thread to finish and clean up, and recover stdout and stderr

Definition at line 830 of file ProgressNCurses.cpp.

References std::fclose(), m_stderr, m_stderr_original, m_stderr_pipe, m_stdout_original, m_stdout_pipe, and m_ui_thread.

Here is the call graph for this function:

Member Function Documentation

void SourceXtractor::ProgressNCurses::Dashboard::ncursesMode ( )
inlineprivate

When we enter we are in ncurses, when we exit we are not (yay RAII)

Definition at line 719 of file ProgressNCurses.cpp.

References SourceXtractor::Screen::initColor(), m_log_text, m_progress_info, m_progress_info_mutex, m_stderr, m_stderr_pipe, m_stdout_pipe, m_trigger_resize, SourceXtractor::signal_fds, and std::snprintf().

Referenced by uiThread().

Here is the call graph for this function:

void SourceXtractor::ProgressNCurses::Dashboard::uiThread ( )
inlineprivate

Main UI thread. All (almost) ncurses handling should be done here, as it is not thread safe

Definition at line 693 of file ProgressNCurses.cpp.

References std::endl(), m_log_text, SourceXtractor::ncurses_done::m_semaphore, m_stderr_original, m_stdout_original, and ncursesMode().

Referenced by Dashboard().

Here is the call graph for this function:

void SourceXtractor::ProgressNCurses::Dashboard::update ( const std::list< ProgressInfo > &  info)
inline

Update the progress information

Definition at line 853 of file ProgressNCurses.cpp.

References m_progress_info, m_progress_info_mutex, m_trigger_resize, and std::list< T >::size().

Here is the call graph for this function:

Member Data Documentation

std::vector<std::string> SourceXtractor::ProgressNCurses::Dashboard::m_log_text
private

Definition at line 686 of file ProgressNCurses.cpp.

Referenced by ncursesMode(), and uiThread().

std::list<ProgressInfo> SourceXtractor::ProgressNCurses::Dashboard::m_progress_info
private

Definition at line 676 of file ProgressNCurses.cpp.

Referenced by ncursesMode(), and update().

std::mutex SourceXtractor::ProgressNCurses::Dashboard::m_progress_info_mutex
private

Definition at line 677 of file ProgressNCurses.cpp.

Referenced by ncursesMode(), and update().

FILE* SourceXtractor::ProgressNCurses::Dashboard::m_stderr
private

Definition at line 681 of file ProgressNCurses.cpp.

Referenced by Dashboard(), ncursesMode(), and ~Dashboard().

int SourceXtractor::ProgressNCurses::Dashboard::m_stderr_original
private

Definition at line 680 of file ProgressNCurses.cpp.

Referenced by Dashboard(), uiThread(), and ~Dashboard().

int SourceXtractor::ProgressNCurses::Dashboard::m_stderr_pipe
private

Definition at line 680 of file ProgressNCurses.cpp.

Referenced by Dashboard(), ncursesMode(), and ~Dashboard().

int SourceXtractor::ProgressNCurses::Dashboard::m_stdout_original
private

Definition at line 683 of file ProgressNCurses.cpp.

Referenced by Dashboard(), uiThread(), and ~Dashboard().

int SourceXtractor::ProgressNCurses::Dashboard::m_stdout_pipe
private

Definition at line 683 of file ProgressNCurses.cpp.

Referenced by Dashboard(), ncursesMode(), and ~Dashboard().

std::atomic_bool SourceXtractor::ProgressNCurses::Dashboard::m_trigger_resize
private

Definition at line 688 of file ProgressNCurses.cpp.

Referenced by ncursesMode(), and update().

std::unique_ptr<boost::thread> SourceXtractor::ProgressNCurses::Dashboard::m_ui_thread
private

Definition at line 675 of file ProgressNCurses.cpp.

Referenced by Dashboard(), and ~Dashboard().


The documentation for this class was generated from the following file: