Navigation



Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libfdproto/fifo.c

    r1067 r1073  
    152152                for (li = queue->list.next; li != &queue->list; li = li->next) {
    153153                        struct fifo_item * fi = (struct fifo_item *)li;
    154                         fd_log_debug("  [%i] item %p in fifo %p, posted:ld.%06ld",
     154                        fd_log_debug("  [%i] item %p in fifo %p, posted:%ld.%06ld",
    155155                                i++, fi->item.o, queue, (long)fi->posted_on.tv_sec,(long)(fi->posted_on.tv_nsec/1000));
    156156                        (*dump_item)(level, fi->item.o);
     
    284284}
    285285
    286 /* Get the length of the queue */
    287 int fd_fifo_length ( struct fifo * queue, int * length, int * max )
    288 {
    289         TRACE_ENTRY( "%p %p %p", queue, length, max );
     286/* Get the information on the queue */
     287int fd_fifo_getstats( struct fifo * queue, int * current_count, int * limit_count, int * highest_count, long long * total_count,
     288                                           struct timespec * total, struct timespec * blocking, struct timespec * last)
     289{
     290        TRACE_ENTRY( "%p %p %p %p %p %p %p %p", queue, current_count, limit_count, highest_count, total_count, total, blocking, last);
    290291       
    291292        /* Check the parameters */
    292         CHECK_PARAMS( CHECK_FIFO( queue ) && length );
     293        CHECK_PARAMS( CHECK_FIFO( queue ) );
    293294       
    294295        /* lock the queue */
    295296        CHECK_POSIX(  pthread_mutex_lock( &queue->mtx )  );
    296297       
    297         /* Retrieve the count */
    298         *length = queue->count;
    299        
    300         if (max)
    301                 *max = queue->max;
     298        if (current_count)
     299                *current_count = queue->count;
     300       
     301        if (limit_count)
     302                *limit_count = queue->max;
     303       
     304        if (highest_count)
     305                *highest_count = queue->highest_ever;
     306       
     307        if (total_count)
     308                *total_count = queue->total_items;
     309       
     310        if (total)
     311                memcpy(total, &queue->total_time, sizeof(struct timespec));
     312       
     313        if (blocking)
     314                memcpy(blocking, &queue->blocking_time, sizeof(struct timespec));
     315       
     316        if (last)
     317                memcpy(last, &queue->last_time, sizeof(struct timespec));
    302318       
    303319        /* Unlock */
     
    308324}
    309325
    310 /* Get the timings */
    311 int fd_fifo_getstats( struct fifo * queue, long long *items, struct timespec * total, struct timespec * blocking, struct timespec * last)
    312 {
    313         TRACE_ENTRY( "%p %p %p %p %p", queue, items, total, blocking, last);
    314        
    315         /* Check the parameters */
    316         CHECK_PARAMS( CHECK_FIFO( queue ) );
    317        
    318         /* lock the queue */
    319         CHECK_POSIX(  pthread_mutex_lock( &queue->mtx )  );
    320        
    321         if (items)
    322                 *items = queue->total_items;
    323        
    324         if (total)
    325                 memcpy(total, &queue->total_time, sizeof(struct timespec));
    326        
    327         if (blocking)
    328                 memcpy(blocking, &queue->blocking_time, sizeof(struct timespec));
    329        
    330         if (last)
    331                 memcpy(last, &queue->last_time, sizeof(struct timespec));
    332        
    333         /* Unlock */
    334         CHECK_POSIX(  pthread_mutex_unlock( &queue->mtx )  );
    335        
    336         /* Done */
    337         return 0;
    338 }
    339 
    340326
    341327/* alternate version with no error checking */
    342 int fd_fifo_length_noerr ( struct fifo * queue )
     328int fd_fifo_length ( struct fifo * queue )
    343329{
    344330        if ( !CHECK_FIFO( queue ) )
Note: See TracChangeset for help on using the changeset viewer.