int main(void) { pthread_mutex_init(&mutex, NULL); pthread_cond_init(&full, NULL); pthread_cond_init(&empty, NULL); init_queue(&Q); pthread_create() pthread_cond_destory(&empty); pthread_cond_destory(&full); pthread_mutex_destory(&mutex); return 0; }
int main(int argc, char const *argv[]) { pthread_t pro, con; pthread_mutex_init(&the_mutex, 0); pthread_cond_init(&condc, 0); pthread_cond_init(&condp, 0); pthread_create(&con, 0, consumer, 0); pthread_create(&pro, 0, producer, 0); pthread_join(pro, 0); pthread_join(con, 0); pthread_cond_destory(&condc); pthread_cond_destory(&condp); pthread_mutex_destory(&the_mutex); return 0; }
void destroy_queue(pQueue *q) { pthread_mutex_destory(&(*q)->m_critial); pthread_cond_destory(&(*q)->no_full); pthread_cond_destory(&(*q)->no_empty); }
CThreadPool::~ThreadPool() { if (pthread_cond_destory(&release_cond, NULL)) std::cout << "pthread_cond_destory failed!" << std::endl; if (pthread_cond_destory(&worker_cond, NULL)) std::cout << "pthread_cond_destory failed!" << std::endl; }