mirror of
https://github.com/tailix/libshmemq.git
synced 2025-02-17 15:45:41 -05:00
Rename queue struct attribute
This commit is contained in:
parent
27cf381ac9
commit
d8ba048c35
3 changed files with 7 additions and 7 deletions
|
@ -11,7 +11,7 @@ static const size_t BUFFER1_SIZE = 200;
|
||||||
static const long BUFFER1_MAGIC = 0xCAFEBABE;
|
static const long BUFFER1_MAGIC = 0xCAFEBABE;
|
||||||
|
|
||||||
struct Queue {
|
struct Queue {
|
||||||
size_t offset;
|
size_t read_offset;
|
||||||
|
|
||||||
unsigned char data[];
|
unsigned char data[];
|
||||||
};
|
};
|
||||||
|
|
|
@ -56,12 +56,12 @@ int main()
|
||||||
|
|
||||||
printf("Initialize queues.\n");
|
printf("Initialize queues.\n");
|
||||||
|
|
||||||
queue->offset = 0;
|
queue->read_offset = 0;
|
||||||
|
|
||||||
printf("Main loop.\n");
|
printf("Main loop.\n");
|
||||||
|
|
||||||
while (running) {
|
while (running) {
|
||||||
const struct Message *const message = (struct Message*)queue->data + queue->offset;
|
const struct Message *const message = (struct Message*)queue->data + queue->read_offset;
|
||||||
|
|
||||||
if (message->magic != BUFFER1_MAGIC) {
|
if (message->magic != BUFFER1_MAGIC) {
|
||||||
printf("No messages.\n");
|
printf("No messages.\n");
|
||||||
|
@ -74,13 +74,13 @@ int main()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message->size > BUFFER1_SIZE - sizeof(struct Queue) - queue->offset) {
|
if (message->size > BUFFER1_SIZE - sizeof(struct Queue) - queue->read_offset) {
|
||||||
printf("Buffer return.\n");
|
printf("Buffer return.\n");
|
||||||
queue->offset = 0;
|
queue->read_offset = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
queue->offset += message->size;
|
queue->read_offset += message->size;
|
||||||
|
|
||||||
switch (message->type) {
|
switch (message->type) {
|
||||||
case FINISH:
|
case FINISH:
|
||||||
|
|
|
@ -43,7 +43,7 @@ int main()
|
||||||
|
|
||||||
printf("Initialize queues.\n");
|
printf("Initialize queues.\n");
|
||||||
|
|
||||||
size_t buffer1_offset = queue->offset;
|
size_t buffer1_offset = queue->read_offset;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
const struct Message *const message = (struct Message*)queue->data + buffer1_offset;
|
const struct Message *const message = (struct Message*)queue->data + buffer1_offset;
|
||||||
|
|
Loading…
Add table
Reference in a new issue