dev: update

This commit is contained in:
wwhai
2025-02-18 15:31:32 +08:00
parent 0cf87954ce
commit 780a51cc99
-57
View File
@@ -168,60 +168,3 @@ int channel_recv_nonblocking(Channel *ch, void **data)
pthread_mutex_unlock(&ch->mutex);
return 0;
}
// #include <stdio.h>
// #include <stdlib.h>
// #include <pthread.h>
// #include "channel.h"
// // 发送线程函数
// void* sender(void *arg) {
// Channel *ch = (Channel*)arg;
// int i;
// for (i = 0; i < 5; i++) {
// int *data = (int*)malloc(sizeof(int));
// *data = i;
// if (channel_send_blocking(ch, data) == -1) {
// printf("Channel is closed, cannot send data.\n");
// free(data);
// break;
// }
// printf("Sent: %d\n", *data);
// }
// channel_close(ch);
// return NULL;
// }
// // 接收线程函数
// void* receiver(void *arg) {
// Channel *ch = (Channel*)arg;
// void *data;
// while (1) {
// int ret = channel_recv_blocking(ch, &data);
// if (ret == -1) {
// printf("Channel is closed, no more data to receive.\n");
// break;
// }
// printf("Received: %d\n", *(int*)data);
// free(data);
// }
// return NULL;
// }
// int main() {
// Channel *ch = channel_create(3);
// if (ch == NULL) {
// printf("Failed to create channel.\n");
// return 1;
// }
// pthread_t sender_thread, receiver_thread;
// pthread_create(&sender_thread, NULL, sender, ch);
// pthread_create(&receiver_thread, NULL, receiver, ch);
// pthread_join(sender_thread, NULL);
// pthread_join(receiver_thread, NULL);
// channel_destroy(ch);
// return 0;
// }