fifo -> queue
This commit is contained in:
parent
a877419d69
commit
8ef8ad7ddb
1 changed files with 4 additions and 4 deletions
|
@ -13,21 +13,21 @@ int main(void) {
|
||||||
long val = rand() % 1000;
|
long val = rand() % 1000;
|
||||||
printf("%zu: writing %ld to queue...\n", i, val);
|
printf("%zu: writing %ld to queue...\n", i, val);
|
||||||
if (queue_write(q, &val)) {
|
if (queue_write(q, &val)) {
|
||||||
printf("%zu: successfully wrote %ld to fifo!\n", i, val);
|
printf("%zu: successfully wrote %ld to queue!\n", i, val);
|
||||||
} else {
|
} else {
|
||||||
printf("%zu: failed writing %ld to fifo :-(\n", i, val);
|
printf("%zu: failed writing %ld to queue :-(\n", i, val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (size_t i = 0; i < 50; ++i) {
|
for (size_t i = 0; i < 50; ++i) {
|
||||||
void *val_ptr = queue_read(q);
|
void *val_ptr = queue_read(q);
|
||||||
if (val_ptr == NULL) {
|
if (val_ptr == NULL) {
|
||||||
printf("%zu: fifo is empty!\n", i);
|
printf("%zu: queue is empty!\n", i);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
long val = *(long*)val_ptr;
|
long val = *(long*)val_ptr;
|
||||||
printf("%zu: read %ld from fifo\n", i, val);
|
printf("%zu: read %ld from queue\n", i, val);
|
||||||
free(val_ptr);
|
free(val_ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue