diff --git a/src/channel.cc b/src/channel.cc index 6e882bf..dc2feea 100644 --- a/src/channel.cc +++ b/src/channel.cc @@ -168,60 +168,3 @@ int channel_recv_nonblocking(Channel *ch, void **data) pthread_mutex_unlock(&ch->mutex); return 0; } - -// #include -// #include -// #include -// #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; -// } \ No newline at end of file