Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming.threads > #109
| From | Jonathan de Boyne Pollard <J.deBoynePollard-newsgroups@NTLWorld.COM> |
|---|---|
| Newsgroups | comp.os.ms-windows.programmer.win32, comp.programming.threads |
| Subject | Re: detecting if space is available in a named pipe |
| References | <ipiq5t$ihe$2@speranza.aioe.org> |
| Message-ID | <IU.D20110502.T001822.P5669.Q0@J.de.Boyne.Pollard.localhost> (permalink) |
| Organization | virginmedia.com |
| Date | 2011-05-02 01:18 +0100 |
Cross-posted to 2 groups.
> Is there some equivalent for writing (that is, a function that checks > if named pipe is not full). I would like to not use WriteFile for that. > WriteFile(), or even WriteFileEx(), is exactly what you should be using for that. I can almost hear David Schwartz now: Think about what you are doing and why you want to know what you say you want to know. The only real use for knowing whether there is "more room in the pipe" is to determine whether the next call to WriteFile() will block or not. That's the only thing that such information really tells you (and, depending from client-end application design, may not even tell you that fact). Thus what you are really doing is trying to ensure that calls to WriteFile() never block, and that when they would your thread can do something else until the pipe drains, or at least wait for things other than just the completion of the write I/O request. The proper design for this, which the MSDN Library documentation actually tells you to use pretty much explicitly, is to use overlapped I/O. Use an overlapped I/O capable pipe handle, and WriteFile() with an OVERLAPPED structure to perform overlapped I/O. You can continue doing things, or WaitForMultipleObjects() on both the overlapped I/O event and other things, and pump a new write request down the pipe whenever the preceding asynchronous one completes. Or, in other words: Don't design as if you can poll the pipe status and busy wait. Design so that completion of a write request on the pipe is an event that you can block waiting for in amongst all of the other events that you might be waiting for. Stick with the event-driven paradigm.
Back to comp.programming.threads | Previous | Next — Next in thread | Find similar | Unroll thread
Re: detecting if space is available in a named pipe Jonathan de Boyne Pollard <J.deBoynePollard-newsgroups@NTLWorld.COM> - 2011-05-02 01:18 +0100
Re: detecting if space is available in a named pipe torri <vincent.torri@gmail.com> - 2011-05-02 05:39 +0000
Re: detecting if space is available in a named pipe David Schwartz <davids@webmaster.com> - 2011-05-02 03:55 -0700
Re: detecting if space is available in a named pipe torri <vincent.torri@gmail.com> - 2011-05-02 17:02 +0000
csiph-web