From 7c5bfcc5ae87c4c984a15261d3ea48b5fe4231b5 Mon Sep 17 00:00:00 2001 From: jwestfall Date: Tue, 1 Jan 2019 14:05:19 -0800 Subject: [PATCH] Remove old stdin reading code --- src/lib/base/EventQueue.cpp | 16 -------- src/lib/base/EventQueue.h | 3 -- src/lib/base/NonBlockingStream.cpp | 60 ------------------------------ src/lib/base/NonBlockingStream.h | 49 ------------------------ 4 files changed, 128 deletions(-) delete mode 100644 src/lib/base/NonBlockingStream.cpp delete mode 100644 src/lib/base/NonBlockingStream.h diff --git a/src/lib/base/EventQueue.cpp b/src/lib/base/EventQueue.cpp index 908ed439..bb5f07fc 100644 --- a/src/lib/base/EventQueue.cpp +++ b/src/lib/base/EventQueue.cpp @@ -201,27 +201,11 @@ EventQueue::adoptBuffer(IEventQueueBuffer* buffer) } } -/* -bool -EventQueue::parent_requests_shutdown() const -{ - char ch; - return m_parentStream.try_read_char(ch) && ch == ShutdownCh; -} -*/ - bool EventQueue::getEvent(Event& event, double timeout) { Stopwatch timer(true); retry: - // before handling any events make sure we don't need to shutdown -/* - if (parent_requests_shutdown()) { - event = Event(Event::kQuit); - return false; - } -*/ // if no events are waiting then handle timers and then wait while (m_buffer->isEmpty()) { // handle timers first diff --git a/src/lib/base/EventQueue.h b/src/lib/base/EventQueue.h index a3980f2f..d4fb6ffd 100644 --- a/src/lib/base/EventQueue.h +++ b/src/lib/base/EventQueue.h @@ -26,7 +26,6 @@ #include "base/Stopwatch.h" #include "common/stdmap.h" #include "common/stdset.h" -//#include "base/NonBlockingStream.h" #include @@ -73,7 +72,6 @@ private: bool hasTimerExpired(Event& event); double getNextTimerTimeout() const; void addEventToBuffer(const Event& event); - //bool parent_requests_shutdown() const; private: class Timer { @@ -186,7 +184,6 @@ private: Mutex* m_readyMutex; CondVar* m_readyCondVar; std::queue m_pending; - //NonBlockingStream m_parentStream; }; #define EVENT_TYPE_ACCESSOR(type_) \ diff --git a/src/lib/base/NonBlockingStream.cpp b/src/lib/base/NonBlockingStream.cpp deleted file mode 100644 index d44add15..00000000 --- a/src/lib/base/NonBlockingStream.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2008 Debauchee Open Source Group - * - * This package is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * found in the file LICENSE that should have accompanied this file. - * - * This package is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#if !defined(_WIN32) - -#include "base/NonBlockingStream.h" - -#include // tcgetattr/tcsetattr, read -#include // tcgetattr/tcsetattr -#include -#include -#include - -NonBlockingStream::NonBlockingStream(int fd) : - _fd(fd) -{ - // disable ICANON & ECHO so we don't have to wait for a newline - // before we get data (and to keep it from being echoed back out) - termios ta; - tcgetattr(fd, &ta); - _p_ta_previous = new termios(ta); - ta.c_lflag &= ~(ICANON | ECHO); - tcsetattr(fd, TCSANOW, &ta); - - // prevent IO from blocking so we can poll (read()) - int _cntl_previous = fcntl(fd, F_GETFL); - fcntl(fd, F_SETFL, _cntl_previous | O_NONBLOCK); -} - -NonBlockingStream::~NonBlockingStream() -{ - tcsetattr(_fd, TCSANOW, _p_ta_previous); - fcntl(_fd, F_SETFL, _cntl_previous); - delete _p_ta_previous; -} - -bool NonBlockingStream::try_read_char(char &ch) const -{ - int result = read(_fd, &ch, 1); - if (result == 1) - return true; - assert(result == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)); - return false; -} - -#endif // !defined(_WIN32) diff --git a/src/lib/base/NonBlockingStream.h b/src/lib/base/NonBlockingStream.h deleted file mode 100644 index 4c27762a..00000000 --- a/src/lib/base/NonBlockingStream.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * barrier -- mouse and keyboard sharing utility - * Copyright (C) 2008 Debauchee Open Source Group - * - * This package is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * found in the file LICENSE that should have accompanied this file. - * - * This package is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -// windows doesn't have a unistd.h so this class won't work as-written. -// at the moment barrier doesn't need this functionality on windows so -// it's left as a stub to be optimized out -#if defined(_WIN32) - -class NonBlockingStream -{ -public: - bool try_read_char(char &ch) const { return false; }; -}; - -#else // non-windows platforms - -struct termios; - -class NonBlockingStream -{ -public: - explicit NonBlockingStream(int fd = 0); - ~NonBlockingStream(); - - bool try_read_char(char &ch) const; - -private: - int _fd; - termios * _p_ta_previous; - int _cntl_previous; -}; - -#endif