Re: No, POLL and WAIT
- From: "f0dder" <f0dder_nospam@xxxxxxxxxxxxxxxx>
- Date: Sat, 10 Sep 2005 09:51:23 +0200
hutch-- wrote:
> hmmmmm,
>
>> MSVCRT.DLL is LIBC in dynamic-link form.
>
> Interesting theory about LIBC but the reference material that I posted
> above does not support your assertion aout problems using C runtime
> libraries.
Where's that reference material? As I stated previously, it seems that
my newsserver hasn't caught all threads&replys from google groups.
>> You're waiting on a file, though :)
>
> win32.hlp
> The WaitForSingleObjectEx function returns when one of the following
> occurs:
> The specified object is in the signaled state.
> An I/O completion routine or asynchronous procedure call (APC) is
> queued to the thread.
> ·The time-out interval elapses.
>From MSDN (rewritten in list form for brevity):
The WaitForSingleObject function can wait for the following objects:
Change notification, Console input, Event, Job, Memory resource
notification, Mutex, Process, Semaphore, Thread, Waitable timer
I don't see "file" in that list. If you look under "Synchronization
Objects", you will see:
"In some circumstances, you can also use a file, named pipe, or
communications device as a synchronization object; however, their use for
this purpose is discouraged. Instead, use asynchronous I/O and wait on the
event object set in the OVERLAPPED structure."
Yes, you can wait on a file handle that refers to a console, and yes in many
cases you can obtain this handle with GetStdHandle. Problem is, standard
handles can be redirected, so to be on the safe side, you really do need to
CreateFile with CONIN$ as argument.
>> GetStdHandle doesn't necessarily return a console handle,
>
> win32.hlp
> The GetStdHandle function returns a handle for the standard input,
> standard output, or standard error device. With keystrokes, its
> standard input.
....and standard in/out/error can be redirected.
>> Pretty pointless to use WaitForObject on the console handle anyway,
>> ReadConsoleInput blocks until you get an event.
>
> win32.hlp
>> The WaitForSingleObject function can wait for the following objects:
> ......
> Console input
> The handle is returned by the CreateFile function when the CONIN$
> value is specified, or by the GetStdHandle function.
....and standard in/out/error can be redirected.
> The object's state is signaled when there is unread input in the console's
> input buffer, and it is nonsignaled when the input buffer is empty.
....and there are other possible events than "a character is ready",
depending on the mode the console is in.
> The problem with WaitForSingleObjectEx() is that it is broken on
> console input due to its undocemented latency clearing the last
> signalled state. So much for its virtues in synchronisation.
Or, more likely, we have a case of the usual story: hutch-- doesn't
understand the WIN32 API, gets a confusing result, and thus declares the API
function broken.
> It is documented to be able to perform this task but fails under
> easily demonstrated conditions. WaitForSingleObjectEx() is unreliable
> clunky junk.
I'll do some decent research on this once I've had a nap.
And again, why are you using WaitForSingleObject? ReadConsoleInput is
blocking, so there's no need to perform this superfluous API call.
.
- Follow-Ups:
- Re: No, POLL and WAIT
- From: Alex McDonald
- Re: No, POLL and WAIT
- References:
- LOOP and WAIT (was: POLL and WAIT !)
- From: Alex McDonald
- Re: LOOP and WAIT (was: POLL and WAIT !)
- From: hutch--
- Re: LOOP and WAIT
- From: Alex McDonald
- No, POLL and WAIT
- From: hutch--
- Re: No, POLL and WAIT
- From: Alex McDonald
- Re: No, POLL and WAIT
- From: Alex McDonald
- Re: No, POLL and WAIT
- From: hutch--
- Re: No, POLL and WAIT
- From: hutch--
- Re: No, POLL and WAIT
- From: f0dder
- Re: No, POLL and WAIT
- From: hutch--
- Re: No, POLL and WAIT
- From: f0dder
- Re: No, POLL and WAIT
- From: hutch--
- LOOP and WAIT (was: POLL and WAIT !)
- Prev by Date: Re: Question for ¬a\/b
- Next by Date: Re: Question for ¬a\/b
- Previous by thread: Re: No, POLL and WAIT
- Next by thread: Re: No, POLL and WAIT
- Index(es):
Relevant Pages
|