🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.os2.programmer
Article #973

Re: DosReadQueue and Timeouts

#973
From: David Charlap
Date: Wed, 26 Aug 1992 20:44
34 lines
2286 bytes
In article <19920826.040756.330@almaden.ibm.com> peterf@vnet.ibm.com writes:
>1. Create a semaphore (I use a RAM semaphore), and SET it.
>
>2. Create the queue.
>
>3. Do an initial read on the queue, with the NoWait argument = (CHAR)1,
>   and supply the semaphore handle of your semaphore.
>   Try to do this while the queue is empty. You will then get the return-
>   code ERROR_QUE_EMPTY - your semaphore is now registered by the queue
>   subsystem, and will be CLEARed when something arrives in your queue.
>
>4. You can now do a DosSemWait on your semaphore, and use the timeout
>   value as you like.
>
>5. If you get NO_ERROR from DosSemWait, you have element(s) in the queue.
>   SET the semaphore.  Read elements with the same NoWait and semaphore
>   arguments as in 3.  The semaphore will not be registered again until
>   you get ERROR_QUE_EMPTY from DosReadQueue.  You can now GOTO 4, and
>   wait on the semaphore again.
>
>   If you get ERROR_SEM_TIMEOUT from DosSemWait you can do your house-
>   keeping (or whatever). The semaphore will stay SET and registered in
>   the queue subsystem, so you just have to go back to 4 when you're done.

You can start your housekeeping automatically and do your DosSemWait
with no timeouts in a separate thread, if you want/need to get fancy.
Of course, you may need new semaphores to keep the housekeeping from
mucking up the incoming data from the other thread if the housekeeping
is something like garbage collection.
-- 
   |)  David Charlap           "I don't even represent myself
  /|_  dic5340@hertz.njit.edu   sometimes so NJIT is right out!.
 ((|,)
  ~|~  Hi! I am a .signature virus, copy me into your .signature file.
Technical Details
Message-ID: <1992Aug26.204450.18857@njitgw.njit.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!dtix!darwin.sura.net!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!rutgers!njitgw.njit.edu!hertz.njit.edu!dic5340
References: <meek.714371000@fizzy> <19920826.040756.330@almaden.ibm.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!dtix!darwin.sura.net!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!rutgers!njitgw.njit.edu!hertz.njit.edu!dic5340
From: dic5340@hertz.njit.edu (David Charlap)
Newsgroups: comp.os.os2.programmer
Subject: Re: DosReadQueue and Timeouts
Message-ID: <1992Aug26.204450.18857@njitgw.njit.edu>
Date: 26 Aug 92 20:44:50 GMT
References: <meek.714371000@fizzy> <19920826.040756.330@almaden.ibm.com>
Sender: news@njit.edu
Organization: New Jersey Institute of Technology, Newark, N.J.
Lines: 34
Nntp-Posting-Host: hertz.njit.edu