home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume27 / distributed-c-2.1 / part01 / examples / prod_cons / consumer.dc < prev    next >
Encoding:
Text File  |  1993-12-22  |  2.0 KB  |  39 lines

  1. /***************************************************************************
  2.  *                                                                         *
  3.  * @@@@  @@@ @@@@@ @@@@@ @@@@@ @@@ @@@@  @   @ @@@@@ @@@@@ @@@@       @@@  *
  4.  * @   @  @  @       @   @   @  @  @   @ @   @   @   @     @   @     @   @ *
  5.  * @   @  @  @@@@@   @   @@@@@  @  @@@@@ @   @   @   @@@@@ @   @     @     *
  6.  * @   @  @      @   @   @ @    @  @   @ @   @   @   @     @   @     @   @ *
  7.  * @@@@  @@@ @@@@@   @   @  @  @@@ @@@@  @@@@@   @   @@@@@ @@@@       @@@  *
  8.  *                                                                         *
  9.  *              A compiler for distributed programming with C              *
  10.  *                                                                         *
  11.  *                          c o n s u m e r . d c                          *
  12.  *                                                                         *
  13.  *                 Version 1.0      CreationDate: 17.07.91                 *
  14.  *                                    LastUpDate: 17.07.91                 *
  15.  *                                                                         *
  16.  *    Process building a consumer for the producer/consumer example.       *
  17.  *                                                                         *
  18.  *              Copyright (C) 1990,1991 by Christoph Pleier.               *
  19.  *                          All rights reserved!                           *
  20.  ***************************************************************************/
  21.  
  22. #include "config.h"
  23.  
  24. /* definition of the process 'consumer' */
  25. process body consumer(num, buffer_descr)
  26. {
  27.     struct msg_t msg;
  28.  
  29.     /* receive continuously messages from buffer and terminate if
  30.      * the transaction can not be performed within 3 minutes!
  31.      */
  32.     while(1) {
  33.         msg = within 180 ? (buffer_descr@b_read() : (exit(0), msg));
  34.         printf("consumer %d: message from %s: value = %d\n", 
  35.             num, msg.name, msg.value);
  36.         fflush(stdout);
  37.     }
  38. } /* process body consumer */
  39.