예제 #1
0
파일: oo2_3.c 프로젝트: Jelb/BOSC
/*Producer function*/
void *producer(void *param) {
  
  int id = *(int *)param;
  Node *node;
  char elm[10];

  while(do_produce()) {
    Sleep(1000);
    
    sem_wait(&sem_count);
    sprintf(elm,"Item_%i",product_count);
    product_count++;
    sem_post(&sem_count);
    
    node = node_new_str(elm);

    sem_wait(&empty);
    sem_wait(&_mutex);

    list_add(buf, node);
    printf("Producer %4i produced %9s. Items in buffer: %4i (out of %4i)\n", id, elm, buf->len, b);
    
    sem_post(&_mutex);
    sem_post(&full);    
  }

  pthread_exit(0);
}
예제 #2
0
int main_0073_headers (int argc, char **argv) {
        const char *topic = test_mk_topic_name(__FUNCTION__ + 5, 1);
        const int msgcnt = 10;

        do_produce(topic, msgcnt);
        do_consume(topic, msgcnt);

        return 0;
}