/[svn]/linuxsampler/trunk/src/shell/KeyboardReader.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/shell/KeyboardReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3765 by schoenebeck, Fri Jun 23 12:24:58 2017 UTC revision 3766 by schoenebeck, Mon Apr 6 12:41:49 2020 UTC
# Line 1  Line 1 
1  /*  /*
2   * LSCP Shell   * LSCP Shell
3   *   *
4   * Copyright (c) 2014 - 2017 Christian Schoenebeck   * Copyright (c) 2014 - 2020 Christian Schoenebeck
5   *   *
6   * This program is part of LinuxSampler and released under the same terms.   * This program is part of LinuxSampler and released under the same terms.
7   */   */
# Line 37  void KeyboardReader::callback(bool b) { Line 37  void KeyboardReader::callback(bool b) {
37  }  }
38    
39  int KeyboardReader::Main() {  int KeyboardReader::Main() {
40        #if DEBUG
41        Thread::setNameOfCaller("KeyboardReader");
42        #endif
43    
44      while (true) {      while (true) {
45          std::vector<char> v = TerminalCtrl::getChars(1, 1);          std::vector<char> v = TerminalCtrl::getChars(1, 1);
46          if (!v.empty()) {          if (!v.empty()) {
47                // prevent thread from being cancelled
48                // (e.g. to prevent deadlocks while holding mutex lock(s))
49                pushCancelable(false);
50    
51              m_fifoMutex.Lock();              m_fifoMutex.Lock();
52              m_fifo.push_back(v[0]);              m_fifo.push_back(v[0]);
53              if (m_sync.GetUnsafe()) {              if (m_sync.GetUnsafe()) {
# Line 56  int KeyboardReader::Main() { Line 64  int KeyboardReader::Main() {
64                  m_fifoMutex.Unlock();                  m_fifoMutex.Unlock();
65                  if (m_callback && m_doCallback) (*m_callback)(this);                  if (m_callback && m_doCallback) (*m_callback)(this);
66              }              }
67    
68                // now allow thread being cancelled again
69                // (since all mutexes are now unlocked)
70                popCancelable();
71          }          }
72          TestCancel();          TestCancel();
73      }      }

Legend:
Removed from v.3765  
changed lines
  Added in v.3766

  ViewVC Help
Powered by ViewVC