home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / messages / src / waitport.c < prev   
Encoding:
C/C++ Source or Header  |  1996-07-16  |  1.6 KB  |  72 lines

  1. /*
  2.     $Id$
  3.     $Log$
  4.     Desc:
  5.     Lang: english
  6. */
  7. #include "exec_intern.h"
  8. #include <exec/ports.h>
  9.  
  10. /*****************************************************************************
  11.  
  12.     NAME */
  13.     #include <clib/exec_protos.h>
  14.  
  15.     __AROS_LH1(struct Message *, WaitPort,
  16.  
  17. /*  SYNOPSIS */
  18.     __AROS_LA(struct MsgPort *, port, A0),
  19.  
  20. /*  LOCATION */
  21.     struct ExecBase *, SysBase, 64, Exec)
  22.  
  23. /*  FUNCTION
  24.     Wait until a message arrives at the given port. If there is already
  25.     a message in it this function returns immediately.
  26.  
  27.     INPUTS
  28.     port    - Pointer to messageport.
  29.  
  30.     RESULT
  31.     Pointer to the first message that arrived at the port. The message
  32.     is _not_ removed from the port. GetMsg() does this for you.
  33.  
  34.     NOTES
  35.  
  36.     EXAMPLE
  37.  
  38.     BUGS
  39.  
  40.     SEE ALSO
  41.     WaitPort(), GetMsg()
  42.  
  43.     INTERNALS
  44.  
  45.     HISTORY
  46.     29-10-95    digulla automatically created from
  47.                 exec_lib.fd and clib/exec_protos.h
  48.     17-12-95    digulla Incorporated code by Matthias Fleischner
  49.  
  50. *****************************************************************************/
  51. {
  52.     __AROS_FUNC_INIT
  53.     /*
  54.     No Disable() necessary here since emptiness can be checked
  55.     without and nobody is allowed to change the signal bit as soon
  56.     as the current task entered WaitPort() (and probably did not yet
  57.     have a chance to Disable()).
  58.     */
  59.  
  60.     /* Is messageport empty? */
  61.     while(port->mp_MsgList.lh_Head->ln_Succ==NULL)
  62.     /*
  63.         Yes. Wait for the signal to arrive. Remember that signals may
  64.         arrive without a message so check again.
  65.     */
  66.     Wait(1<<port->mp_SigBit);
  67.  
  68.     /* Return the first node in the list. */
  69.     return (struct Message *)port->mp_MsgList.lh_Head;
  70.     __AROS_FUNC_EXIT
  71. } /* WaitPort */
  72.