mirror of
https://git.openldap.org/openldap/openldap.git
synced 2024-12-27 03:20:22 +08:00
ITS#8858 Introduce ldap_pvt_thread_pool_walk
This commit is contained in:
parent
7127d5db11
commit
d4df939b95
@ -220,6 +220,7 @@ ldap_pvt_thread_rdwr_active LDAP_P((ldap_pvt_thread_rdwr_t *rdwrp));
|
|||||||
typedef ldap_int_thread_pool_t ldap_pvt_thread_pool_t;
|
typedef ldap_int_thread_pool_t ldap_pvt_thread_pool_t;
|
||||||
|
|
||||||
typedef void * (ldap_pvt_thread_start_t) LDAP_P((void *ctx, void *arg));
|
typedef void * (ldap_pvt_thread_start_t) LDAP_P((void *ctx, void *arg));
|
||||||
|
typedef int (ldap_pvt_thread_walk_t) LDAP_P((ldap_pvt_thread_start_t *start, void *start_arg, void *arg));
|
||||||
typedef void (ldap_pvt_thread_pool_keyfree_t) LDAP_P((void *key, void *data));
|
typedef void (ldap_pvt_thread_pool_keyfree_t) LDAP_P((void *key, void *data));
|
||||||
#endif /* !LDAP_PVT_THREAD_H_DONE */
|
#endif /* !LDAP_PVT_THREAD_H_DONE */
|
||||||
|
|
||||||
@ -253,6 +254,13 @@ LDAP_F( int )
|
|||||||
ldap_pvt_thread_pool_retract LDAP_P((
|
ldap_pvt_thread_pool_retract LDAP_P((
|
||||||
void *cookie ));
|
void *cookie ));
|
||||||
|
|
||||||
|
LDAP_F( int )
|
||||||
|
ldap_pvt_thread_pool_walk LDAP_P((
|
||||||
|
ldap_pvt_thread_pool_t *pool,
|
||||||
|
ldap_pvt_thread_start_t *start,
|
||||||
|
ldap_pvt_thread_walk_t *cb,
|
||||||
|
void *arg ));
|
||||||
|
|
||||||
LDAP_F( int )
|
LDAP_F( int )
|
||||||
ldap_pvt_thread_pool_maxthreads LDAP_P((
|
ldap_pvt_thread_pool_maxthreads LDAP_P((
|
||||||
ldap_pvt_thread_pool_t *pool,
|
ldap_pvt_thread_pool_t *pool,
|
||||||
|
@ -516,6 +516,46 @@ ldap_pvt_thread_pool_retract (
|
|||||||
return task != NULL;
|
return task != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Walk the pool and allow tasks to be retracted, only to be called while the
|
||||||
|
* pool is paused */
|
||||||
|
int
|
||||||
|
ldap_pvt_thread_pool_walk(
|
||||||
|
ldap_pvt_thread_pool_t *tpool,
|
||||||
|
ldap_pvt_thread_start_t *start,
|
||||||
|
ldap_pvt_thread_walk_t *cb, void *arg )
|
||||||
|
{
|
||||||
|
struct ldap_int_thread_pool_s *pool;
|
||||||
|
struct ldap_int_thread_poolq_s *pq;
|
||||||
|
ldap_int_thread_task_t *task;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
if (tpool == NULL)
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
pool = *tpool;
|
||||||
|
|
||||||
|
if (pool == NULL)
|
||||||
|
return(-1);
|
||||||
|
|
||||||
|
ldap_pvt_thread_mutex_lock(&pool->ltp_mutex);
|
||||||
|
assert(pool->ltp_pause == PAUSED);
|
||||||
|
ldap_pvt_thread_mutex_unlock(&pool->ltp_mutex);
|
||||||
|
|
||||||
|
for (i=0; i<pool->ltp_numqs; i++) {
|
||||||
|
pq = pool->ltp_wqs[i];
|
||||||
|
LDAP_STAILQ_FOREACH(task, &pq->ltp_pending_list, ltt_next.q) {
|
||||||
|
if ( task->ltt_start_routine == start ) {
|
||||||
|
if ( cb( task->ltt_start_routine, task->ltt_arg, arg ) ) {
|
||||||
|
/* retract */
|
||||||
|
task->ltt_start_routine = no_task;
|
||||||
|
task->ltt_arg = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Set number of work queues in this pool. Should not be
|
/* Set number of work queues in this pool. Should not be
|
||||||
* more than the number of CPUs. */
|
* more than the number of CPUs. */
|
||||||
int
|
int
|
||||||
|
Loading…
Reference in New Issue
Block a user