Electroneum
Loading...
Searching...
No Matches
epee::async_stdin_reader Class Reference

#include <console_handler.h>

Public Member Functions

 async_stdin_reader ()
 ~async_stdin_reader ()
bool get_line (std::string &line)
bool eos () const
void stop ()

Detailed Description

Definition at line 50 of file console_handler.h.

Constructor & Destructor Documentation

◆ async_stdin_reader()

epee::async_stdin_reader::async_stdin_reader ( )
inline

Definition at line 53 of file console_handler.h.

54 : m_run(true)
55 , m_has_read_request(false)
56 , m_read_status(state_init)
57 {
58#ifdef HAVE_READLINE
59 m_readline_buffer.start();
60#endif
61 m_reader_thread = boost::thread(std::bind(&async_stdin_reader::reader_thread_func, this));
62 }

◆ ~async_stdin_reader()

epee::async_stdin_reader::~async_stdin_reader ( )
inline

Definition at line 64 of file console_handler.h.

65 {
66 try { stop(); }
67 catch (...) { /* ignore */ }
68 }
Here is the call graph for this function:

Member Function Documentation

◆ eos()

bool epee::async_stdin_reader::eos ( ) const
inline

Definition at line 105 of file console_handler.h.

105{ return m_read_status == state_eos; }
Here is the caller graph for this function:

◆ get_line()

bool epee::async_stdin_reader::get_line ( std::string & line)
inline

Definition at line 78 of file console_handler.h.

79 {
80 if (!start_read())
81 return false;
82
83 if (state_eos == m_read_status)
84 return false;
85
86 boost::unique_lock<boost::mutex> lock(m_response_mutex);
87 while (state_init == m_read_status)
88 {
89 m_response_cv.wait(lock);
90 }
91
92 bool res = false;
93 if (state_success == m_read_status)
94 {
95 line = m_line;
96 res = true;
97 }
98
99 if (!eos())
100 m_read_status = state_init;
101
102 return res;
103 }
const char * res
Here is the call graph for this function:

◆ stop()

void epee::async_stdin_reader::stop ( )
inline

Definition at line 107 of file console_handler.h.

108 {
109 if (m_run)
110 {
111 m_run.store(false, std::memory_order_relaxed);
112
113#if defined(WIN32)
114 ::CloseHandle(::GetStdHandle(STD_INPUT_HANDLE));
115#endif
116
117 m_request_cv.notify_one();
118 m_reader_thread.join();
119#ifdef HAVE_READLINE
120 m_readline_buffer.stop();
121#endif
122 }
123 }
Here is the caller graph for this function:

The documentation for this class was generated from the following file:
  • /home/abuild/rpmbuild/BUILD/electroneum-5.1.3.1-build/electroneum-5.1.3.1/contrib/epee/include/console_handler.h