Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
ex_thread_pool_wait.c File Reference

wait_for_threaded_pool must return when a proc that was STILL RUNNING at the moment of the call finishes. More...

#include "nilorea/n_common.h"
#include "nilorea/n_log.h"
#include "nilorea/n_thread_pool.h"
#include <stdio.h>
#include <unistd.h>
Include dependency graph for ex_thread_pool_wait.c:

Go to the source code of this file.

Functions

int main (void)
static void * slow_proc (void *p)

Detailed Description

wait_for_threaded_pool must return when a proc that was STILL RUNNING at the moment of the call finishes.

That ordering is the one that used to strand the caller: the idle token is posted by refresh_thread_pool only, and the post was guarded by reading sem_getvalue, whose result POSIX leaves unspecified while a thread is blocked in sem_wait. Where that read is not zero for a blocked waiter (winpthreads reports a negative waiter count) the post was skipped and the waiter never woke. glibc reports zero, so this passes on Linux either way; it is a guard against reintroducing the dependency, and it fails outright anywhere the value differs.

Author
Castagnier Mickael
Version
1.0

Definition in file ex_thread_pool_wait.c.

Function Documentation

◆ main()

int main ( void )

Definition at line 42 of file ex_thread_pool_wait.c.

References add_threaded_process(), destroy_threaded_pool(), LOG_ERR, new_thread_pool(), NORMAL_PROC, pool, set_log_level(), slow_proc(), and wait_for_threaded_pool().

Here is the call graph for this function:

◆ slow_proc()

void * slow_proc ( void * p)
static

Definition at line 36 of file ex_thread_pool_wait.c.

Referenced by main().

Here is the caller graph for this function: