You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.3 KiB
45 lines
1.3 KiB
#include "../lib/ll_queue.h" |
|
#include "../lib/u_async.h" |
|
#include <stdio.h> |
|
#include <stdlib.h> |
|
#include <string.h> |
|
|
|
typedef struct { |
|
int id; |
|
char name[32]; |
|
int value; |
|
} test_data_t; |
|
|
|
int main() { |
|
struct UASYNC* ua = uasync_create(); |
|
struct ll_queue* q = queue_new(ua, 0,"s1"); |
|
|
|
/* Create test data */ |
|
test_data_t* data1 = (test_data_t*)queue_entry_new(sizeof(test_data_t)); |
|
printf("queue_entry_new returned: %p\n", data1); |
|
|
|
data1->id = 1; |
|
strcpy(data1->name, "test1"); |
|
data1->value = 100; |
|
|
|
printf("Created data: id=%d, name=%s, value=%d\n", data1->id, data1->name, data1->value); |
|
printf("Data pointer: %p\n", data1); |
|
|
|
/* Put data into queue */ |
|
int put_result = queue_data_put(q, data1); |
|
printf("queue_data_put returned: %d\n", put_result); |
|
printf("After put: queue count = %d\n", queue_entry_count(q)); |
|
|
|
/* Get data from queue */ |
|
test_data_t* retrieved = (test_data_t*)queue_data_get(q); |
|
printf("Retrieved pointer: %p\n", retrieved); |
|
if (retrieved) { |
|
printf("Retrieved data: id=%d, name=%s, value=%d\n", retrieved->id, retrieved->name, retrieved->value); |
|
} else { |
|
printf("Retrieved NULL!\n"); |
|
} |
|
|
|
queue_free(q); |
|
uasync_destroy(ua, 0); |
|
return 0; |
|
}
|
|
|