mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-19 19:03:07 +02:00
Delay Decrease
- Reduced the delay to 1ms. Note: this is still a hack. - Added error checking around the 'select' call.
This commit is contained in:
parent
c5d3042bbf
commit
deb12102f6
1 changed files with 17 additions and 15 deletions
32
src/A3.cpp
32
src/A3.cpp
|
@ -279,28 +279,30 @@ bool A3::is_command (
|
|||
// Add an Arg for every word from std::cin.
|
||||
void A3::append_stdin ()
|
||||
{
|
||||
// Delay, to give it a chance to buffer the input.
|
||||
delay (0.05);
|
||||
|
||||
// Use 'select' to determine whether there is any std::cin content buffered
|
||||
// before trying to read it, to prevent blocking.
|
||||
struct timeval tv;
|
||||
fd_set fds;
|
||||
tv.tv_sec = 0;
|
||||
tv.tv_usec = 0;
|
||||
tv.tv_usec = 1000;
|
||||
|
||||
fd_set fds;
|
||||
FD_ZERO (&fds);
|
||||
FD_SET (STDIN_FILENO, &fds);
|
||||
select (STDIN_FILENO + 1, &fds, NULL, NULL, &tv);
|
||||
if (FD_ISSET (0, &fds))
|
||||
{
|
||||
std::string arg;
|
||||
while (std::cin >> arg)
|
||||
{
|
||||
// It the terminator token is found, stop reading.
|
||||
if (arg == "--")
|
||||
break;
|
||||
|
||||
this->push_back (Arg (arg));
|
||||
int result = select (STDIN_FILENO + 1, &fds, NULL, NULL, &tv);
|
||||
if (result && result != -1)
|
||||
{
|
||||
if (FD_ISSET (0, &fds))
|
||||
{
|
||||
std::string arg;
|
||||
while (std::cin >> arg)
|
||||
{
|
||||
// It the terminator token is found, stop reading.
|
||||
if (arg == "--")
|
||||
break;
|
||||
|
||||
this->push_back (Arg (arg));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue