Cancel cin

  • Thread starter Mike - EMAIL IGNORED
  • Start date
M

Mike - EMAIL IGNORED

Using RoseRT with RedHat 8.0, I have a thread that is
waiting for a cin, and another thread that wants to
cancel the cin without waiting for a response from
the keyboard. I tried destroying the thread that
issued the cin, but it didn't die until the keyboard
responded. Any suggestions?

Thanks in advance for your help.

Mike.
 
V

Victor Bazarov

Mike - EMAIL IGNORED said:
Using RoseRT with RedHat 8.0, I have a thread that is
waiting for a cin, and another thread that wants to
cancel the cin without waiting for a response from
the keyboard. I tried destroying the thread that
issued the cin, but it didn't die until the keyboard
responded. Any suggestions?

What does it mean "to cancel the cin"? Also, consider
posting to a newsgroup where threads are on topic, like
your OS newsgroup or comp.programming.threads. C++ has
no means to manage threads yet. It's all platform-
specific.

V
 
M

Mike - EMAIL IGNORED

Victor said:
What does it mean "to cancel the cin"? Also, consider
posting to a newsgroup where threads are on topic, like
your OS newsgroup or comp.programming.threads. C++ has
no means to manage threads yet. It's all platform-
specific.

V

By "to cancel the cin" I mean to cause the cin to stop block
ing and waiting for input. Also, later I might want to issue
another cin. Thanks four your advice on where to post -- we
are way ahead of you. I was under the impression that cin has
something to do with C++.

Mike.
 
R

Rolf Magnus

Mike said:
By "to cancel the cin" I mean to cause the cin to stop block
ing and waiting for input.

cin is an object. You can't "cancel" objects. That's what confuses
people here. What you probably meant was cancelling an input operation
that reads from cin.
Also, later I might want to issue another cin.

cin is still the same object.
Thanks four your advice on where to post -- we are way ahead of you.
I was under the impression that cin has something to do with C++.

Yes, cin is part of C++, but again, threads are _not_. But if you don't
have threads, cancelling a blocking operation doesn't make sense (who
would cancel it, if not another thread?), and so there is no way to do
that in standard C++.
 
B

Buster

Mike said:
By "to cancel the cin" I mean to cause the cin to stop block
ing and waiting for input. Also, later I might want to issue
another cin. Thanks four your advice on where to post -- we
are way ahead of you. I was under the impression that cin has
something to do with C++.

There is only one "cin", and its name is "cin" or "std::cin", not "the
cin". It's an object, not something you can "issue", "cancel" or do
anything else with apart from calling the functions in its public
interface, istream.

Your question is off-topic in this newsgroup. There's no point in being
cross when someone points that out.

Your problem is that terminal input with cin is not flexible enough to
do what you want to do. What you need to do is possible (examine the
readline library sources for hints) but not portably. It might be easier
to write an X application and use events for control. This is how most
"real-time" interactive programs are written (perhaps you have noticed
this).

Regards,
Buster.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top