MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / pthread_cond_destroy

Function pthread_cond_destroy

components/libc/posix/pthreads/pthread_cond.c:161–191  ·  view source on GitHub ↗

* @brief Destroys a condition variable. * * This function destroys the condition variable pointed to by `cond`. After a condition * variable is destroyed, it must not be used until it is reinitialized with * `pthread_cond_init`. * * @param cond A pointer to the condition variable to be destroyed. * Must point to a valid, previously initialized condition variable. * * @return

Source from the content-addressed store, hash-verified

159 * @see pthread_cond_init, pthread_cond_wait, pthread_cond_signal, pthread_cond_broadcast
160 */
161int pthread_cond_destroy(pthread_cond_t *cond)
162{
163 rt_err_t result;
164 if (cond == RT_NULL)
165 {
166 return EINVAL;
167 }
168 /* which is not initialized */
169 if (cond->attr == -1)
170 {
171 return 0;
172 }
173
174 if (!rt_list_isempty(&cond->sem.parent.suspend_thread))
175 {
176 return EBUSY;
177 }
178__retry:
179 result = rt_sem_trytake(&(cond->sem));
180 if (result == EBUSY)
181 {
182 pthread_cond_broadcast(cond);
183 goto __retry;
184 }
185
186 /* clean condition */
187 rt_memset(cond, 0, sizeof(pthread_cond_t));
188 cond->attr = -1;
189
190 return 0;
191}
192RTM_EXPORT(pthread_cond_destroy);
193
194/**

Callers 3

pthread_barrier_destroyFunction · 0.85
pthread_rwlock_destroyFunction · 0.85
rt_hw_sdl_startFunction · 0.85

Calls 4

rt_list_isemptyFunction · 0.85
rt_sem_trytakeFunction · 0.85
pthread_cond_broadcastFunction · 0.85
rt_memsetFunction · 0.85

Tested by

no test coverage detected