Remove old stdin reading code

This commit is contained in:
jwestfall 2019-01-01 14:05:19 -08:00
parent c67ad71c90
commit 7c5bfcc5ae
4 changed files with 0 additions and 128 deletions

View File

@ -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

View File

@ -26,7 +26,6 @@
#include "base/Stopwatch.h"
#include "common/stdmap.h"
#include "common/stdset.h"
//#include "base/NonBlockingStream.h"
#include <queue>
@ -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<bool>* m_readyCondVar;
std::queue<Event> m_pending;
//NonBlockingStream m_parentStream;
};
#define EVENT_TYPE_ACCESSOR(type_) \

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#if !defined(_WIN32)
#include "base/NonBlockingStream.h"
#include <unistd.h> // tcgetattr/tcsetattr, read
#include <termios.h> // tcgetattr/tcsetattr
#include <fcntl.h>
#include <errno.h>
#include <assert.h>
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)

View File

@ -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 <http://www.gnu.org/licenses/>.
*/
#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