Yurttas/PL/OOL/Cplusplus/F/02/08/01/00/producer.cpp
Jump to navigation
Jump to search
1/*
2 Copyright(C) 2005
3 All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
4
5 Permission to use, copy, modify, and distribute this
6 software and its documentation for EDUCATIONAL purposes
7 and without fee is hereby granted provided that this
8 copyright notice appears in all copies.
9
10 date : September 1, 2005.
11 author : Austin W. Westfall, Salih Yurttas.
12
13 producer.cpp
14*/
15
16
17#include <unistd.h>
18
19#include "producer.h"
20
21producer::
22producer(cubby_hole<int>* c,
23 const int pid) : ch(c),
24 id(pid),
25 num_items(0) {
26}
27
28void
29producer::
30produce(const int a) {
31 num_items = a;
32 start();
33}
34
35void
36producer::
37run() {
38 for(int i=0; i<num_items; ++i) {
39 ch->put(i);
40 cout << "Producer #" << id << " put: " << i << endl;
41 usleep(160);
42 }
43}