Back to index

openldap  2.4.31
Classes | Typedefs | Functions
ldap_rq.h File Reference
#include <ldap_cdefs.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  re_s
struct  runqueue_s

Typedefs

typedef LDAP_BEGIN_DECL struct re_s re_t
typedef struct runqueue_s runqueue_t

Functions

 ldap_pvt_runqueue_insert (struct runqueue_s *rq, time_t interval, ldap_pvt_thread_start_t *routine, void *arg, char *tname, char *tspec)
 ldap_pvt_runqueue_find (struct runqueue_s *rq, ldap_pvt_thread_start_t *routine, void *arg)
 ldap_pvt_runqueue_remove (struct runqueue_s *rq, struct re_s *entry)
 ldap_pvt_runqueue_next_sched (struct runqueue_s *rq, struct timeval *next_run)
 ldap_pvt_runqueue_runtask (struct runqueue_s *rq, struct re_s *entry)
 ldap_pvt_runqueue_stoptask (struct runqueue_s *rq, struct re_s *entry)
 ldap_pvt_runqueue_isrunning (struct runqueue_s *rq, struct re_s *entry)
 ldap_pvt_runqueue_resched (struct runqueue_s *rq, struct re_s *entry, int defer)
 ldap_pvt_runqueue_persistent_backload (struct runqueue_s *rq)

Typedef Documentation

typedef LDAP_BEGIN_DECL struct re_s re_t
typedef struct runqueue_s runqueue_t

Function Documentation

ldap_pvt_runqueue_find ( struct runqueue_s rq,
ldap_pvt_thread_start_t *  routine,
void arg 
) [read]

Definition at line 64 of file rq.c.

{
       struct re_s* e;

       LDAP_STAILQ_FOREACH( e, &rq->task_list, tnext ) {
              if ( e->routine == routine && e->arg == arg )
                     return e;
       }
       return NULL;
}

Here is the caller graph for this function:

ldap_pvt_runqueue_insert ( struct runqueue_s rq,
time_t  interval,
ldap_pvt_thread_start_t *  routine,
void arg,
char *  tname,
char *  tspec 
) [read]

Definition at line 37 of file rq.c.

{
       struct re_s* entry;

       entry = (struct re_s *) LDAP_CALLOC( 1, sizeof( struct re_s ));
       if ( entry ) {
              entry->interval.tv_sec = interval;
              entry->interval.tv_usec = 0;
              entry->next_sched.tv_sec = time( NULL );
              entry->next_sched.tv_usec = 0;
              entry->routine = routine;
              entry->arg = arg;
              entry->tname = tname;
              entry->tspec = tspec;
              LDAP_STAILQ_INSERT_HEAD( &rq->task_list, entry, tnext );
       }
       return entry;
}

Here is the caller graph for this function:

ldap_pvt_runqueue_isrunning ( struct runqueue_s rq,
struct re_s entry 
)

Definition at line 135 of file rq.c.

{
       struct re_s* e;

       LDAP_STAILQ_FOREACH( e, &rq->run_list, rnext ) {
              if ( e == entry ) {
                     return 1;
              }
       }
       return 0;
}

Here is the caller graph for this function:

ldap_pvt_runqueue_next_sched ( struct runqueue_s rq,
struct timeval *  next_run 
) [read]

Definition at line 100 of file rq.c.

{
       struct re_s* entry;

       entry = LDAP_STAILQ_FIRST( &rq->task_list );
       if ( entry == NULL || entry->next_sched.tv_sec == 0 ) {
              return NULL;
       } else {
              *next_run = entry->next_sched;
              return entry;
       }
}

Here is the caller graph for this function:

Definition at line 204 of file rq.c.

{
       struct re_s* e;
       int count = 0;

       ldap_pvt_thread_mutex_lock( &rq->rq_mutex );
       if ( !LDAP_STAILQ_EMPTY( &rq->task_list )) {
              LDAP_STAILQ_FOREACH( e, &rq->task_list, tnext ) {
                     if ( e->next_sched.tv_sec == 0 )
                            count++;
              }
       }
       ldap_pvt_thread_mutex_unlock( &rq->rq_mutex );
       return count;
}
ldap_pvt_runqueue_remove ( struct runqueue_s rq,
struct re_s entry 
)

Definition at line 80 of file rq.c.

{
       struct re_s* e;

       LDAP_STAILQ_FOREACH( e, &rq->task_list, tnext ) {
              if ( e == entry)
                     break;
       }

       assert( e == entry );

       LDAP_STAILQ_REMOVE( &rq->task_list, entry, re_s, tnext );

       LDAP_FREE( entry );
}

Here is the caller graph for this function:

ldap_pvt_runqueue_resched ( struct runqueue_s rq,
struct re_s entry,
int  defer 
)

Definition at line 151 of file rq.c.

{
       struct re_s* prev;
       struct re_s* e;

       LDAP_STAILQ_FOREACH( e, &rq->task_list, tnext ) {
              if ( e == entry )
                     break;
       }

       assert ( e == entry );

       LDAP_STAILQ_REMOVE( &rq->task_list, entry, re_s, tnext );

       if ( !defer ) {
              entry->next_sched.tv_sec = time( NULL ) + entry->interval.tv_sec;
       } else {
              entry->next_sched.tv_sec = 0;
       }

       if ( LDAP_STAILQ_EMPTY( &rq->task_list )) {
              LDAP_STAILQ_INSERT_HEAD( &rq->task_list, entry, tnext );
       } else if ( entry->next_sched.tv_sec == 0 ) {
              LDAP_STAILQ_INSERT_TAIL( &rq->task_list, entry, tnext );
       } else {
              prev = NULL;
              LDAP_STAILQ_FOREACH( e, &rq->task_list, tnext ) {
                     if ( e->next_sched.tv_sec == 0 ) {
                            if ( prev == NULL ) {
                                   LDAP_STAILQ_INSERT_HEAD( &rq->task_list, entry, tnext );
                            } else {
                                   LDAP_STAILQ_INSERT_AFTER( &rq->task_list, prev, entry, tnext );
                            }
                            return;
                     } else if ( e->next_sched.tv_sec > entry->next_sched.tv_sec ) {
                            if ( prev == NULL ) {
                                   LDAP_STAILQ_INSERT_HEAD( &rq->task_list, entry, tnext );
                            } else {
                                   LDAP_STAILQ_INSERT_AFTER( &rq->task_list, prev, entry, tnext );
                            }
                            return;
                     }
                     prev = e;
              }
              LDAP_STAILQ_INSERT_TAIL( &rq->task_list, entry, tnext );
       }
}

Here is the caller graph for this function:

ldap_pvt_runqueue_runtask ( struct runqueue_s rq,
struct re_s entry 
)

Definition at line 117 of file rq.c.

{
       LDAP_STAILQ_INSERT_TAIL( &rq->run_list, entry, rnext );
}

Here is the caller graph for this function:

ldap_pvt_runqueue_stoptask ( struct runqueue_s rq,
struct re_s entry 
)

Definition at line 126 of file rq.c.

{
       LDAP_STAILQ_REMOVE( &rq->run_list, entry, re_s, rnext );
}

Here is the caller graph for this function: