1 #ifndef LLDB_TEST_API_COMMON_H
2 #define LLDB_TEST_API_COMMON_H
4 #include <condition_variable>
14 /// Simple exception class with a message
15 struct Exception
: public std::exception
18 Exception(std::string ss
) : s(ss
) {}
19 virtual ~Exception() throw () { }
20 const char* what() const throw() { return s
.c_str(); }
23 // Synchronized data structure for listener to send events through
25 class multithreaded_queue
{
26 std::condition_variable m_condition
;
34 std::lock_guard
<std::mutex
> lock(m_mutex
);
37 m_condition
.notify_all();
40 T
pop(int timeout_seconds
, bool &success
) {
42 while (count
< timeout_seconds
) {
43 std::unique_lock
<std::mutex
> lock(m_mutex
);
44 if (!m_data
.empty()) {
46 T ret
= m_data
.front();
50 } else if (!m_notified
)
51 m_condition
.wait_for(lock
, std::chrono::seconds(1));
59 /// Allocates a char buffer with the current working directory
60 inline char* get_working_dir() {
61 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__)
64 return get_current_dir_name();
68 #endif // LLDB_TEST_API_COMMON_H