Update to new code
This commit is contained in:
+1
-1
@@ -18,7 +18,7 @@ void *reader(void *arg)
|
||||
for (i = 0; i < CNT/2; i++) {
|
||||
struct uc_threadmsg *msg;
|
||||
struct my_msg *my;
|
||||
if (uc_thread_queue_get(&queue, NULL, &msg) != 0) {
|
||||
if (uc_thread_queue_get(&queue, &msg) != 0) {
|
||||
printf("uc_threadqueue_get failed\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <errno.h>
|
||||
#include <ucore/ucore_threadqueue.h>
|
||||
|
||||
struct uc_threadqueue queue;
|
||||
@@ -17,7 +18,13 @@ void *handler(void *arg)
|
||||
for (;;) {
|
||||
struct uc_threadmsg *msg;
|
||||
struct my_msg *my;
|
||||
if (uc_thread_queue_get(&queue, NULL, &msg) != 0) {
|
||||
struct timespec timeout = {5, 0};
|
||||
int rc;
|
||||
rc = uc_thread_queue_tryget(&queue, &timeout, &msg);
|
||||
if(rc == ETIMEDOUT) {
|
||||
printf("handler timed out\n");
|
||||
continue;
|
||||
} else if (rc != 0) {
|
||||
printf("uc_threadqueue_get failed\n");
|
||||
return NULL;
|
||||
}
|
||||
@@ -61,6 +68,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
struct my_msg *msg = malloc(sizeof *msg);
|
||||
msg->sig = sig;
|
||||
msg->uc_msg.msgtype = 0;
|
||||
uc_thread_queue_add(&queue, msg);
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user