• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //===-- InputReaderStack.cpp ------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #include "lldb/Core/InputReaderStack.h"
11 
12 // C Includes
13 // C++ Includes
14 // Other libraries and framework includes
15 // Project includes
16 
17 
18 using namespace lldb;
19 using namespace lldb_private;
20 
InputReaderStack()21 InputReaderStack::InputReaderStack () :
22     m_input_readers (),
23     m_input_readers_mutex (Mutex::eMutexTypeRecursive)
24 {
25 }
26 
~InputReaderStack()27 InputReaderStack::~InputReaderStack ()
28 {
29 }
30 
31 size_t
GetSize() const32 InputReaderStack::GetSize () const
33 {
34     Mutex::Locker locker (m_input_readers_mutex);
35     return m_input_readers.size();
36 }
37 
38 void
Push(const lldb::InputReaderSP & reader_sp)39 InputReaderStack::Push (const lldb::InputReaderSP& reader_sp)
40 {
41     if (reader_sp)
42     {
43         Mutex::Locker locker (m_input_readers_mutex);
44         m_input_readers.push (reader_sp);
45     }
46 }
47 
48 bool
IsEmpty() const49 InputReaderStack::IsEmpty () const
50 {
51     Mutex::Locker locker (m_input_readers_mutex);
52     return m_input_readers.empty();
53 }
54 
55 InputReaderSP
Top()56 InputReaderStack::Top ()
57 {
58     InputReaderSP input_reader_sp;
59     {
60         Mutex::Locker locker (m_input_readers_mutex);
61         if (!m_input_readers.empty())
62             input_reader_sp = m_input_readers.top();
63     }
64 
65     return input_reader_sp;
66 }
67 
68 void
Pop()69 InputReaderStack::Pop ()
70 {
71     Mutex::Locker locker (m_input_readers_mutex);
72     if (!m_input_readers.empty())
73         m_input_readers.pop();
74 }
75 
76 Mutex &
GetStackMutex()77 InputReaderStack::GetStackMutex ()
78 {
79     return m_input_readers_mutex;
80 }
81