~jheiss/galera/galera

« back to all changes in this revision

Viewing changes to galerautils/src/gu_fifo.c

  • Committer: Alexey Yurchenko
  • Date: 2013-11-05 14:39:56 UTC
  • mfrom: (153.2.11 2.x)
  • Revision ID: alexey.yurchenko@codership.com-20131105143956-i3ri98560tg47dig
References lp:1240924 - added regression tests for lp:587170, removed stale wsrep_local_bf_aborts. Synced with SVN r 3367.
References lp:1180792 - Galera status variables are no longer implicitly reset to initial values when quering them. Added support for explicit status variables reset. Added flow_control_paused_ns variable that produces total time (nanoseconds) that provider was paused.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2008 Codership Oy <info@codership.com>
 
2
 * Copyright (C) 2008-2013 Codership Oy <info@codership.com>
3
3
 *
4
4
 * Queue (FIFO) class implementation
5
5
 *
10
10
 *
11
11
 * When needed this FIFO can be made very big, holding
12
12
 * millions or even billions of items while taking up
13
 
 * minimum space when there are few items in the queue. 
 
13
 * minimum space when there are few items in the queue.
14
14
 */
15
15
 
16
16
#define _BSD_SOURCE
33
33
    ulong col_shift;
34
34
    ulong col_mask;
35
35
    ulong rows_num;
36
 
    ulong item_size;
37
36
    ulong head;
38
37
    ulong tail;
39
38
    ulong row_size;
40
39
    ulong length;
41
40
    ulong length_mask;
42
 
    ulong used;
43
41
    ulong alloc;
44
42
    long  get_wait;
45
43
    long  put_wait;
46
 
    long  q_len;
47
 
    long  q_len_samples;
 
44
    long long  q_len;
 
45
    long long  q_len_samples;
 
46
    uint  item_size;
 
47
    uint  used;
 
48
    int   get_err;
48
49
    bool  closed;
49
 
    int   get_err;
50
50
 
51
51
    gu_mutex_t   lock;
52
52
    gu_cond_t    get_cond;
383
383
}
384
384
 
385
385
/*! returns how many items were in the queue per push_tail() */
386
 
void gu_fifo_stats (gu_fifo_t* q, long* q_len, double* q_len_avg)
 
386
void gu_fifo_stats_get (gu_fifo_t* q, int* q_len, double* q_len_avg)
387
387
{
388
388
    fifo_lock (q);
389
389
 
390
390
    *q_len = q->used;
391
391
 
392
 
    long len     = q->q_len;
393
 
    long samples = q->q_len_samples;
394
 
 
395
 
    q->q_len = 0;
396
 
    q->q_len_samples = 0;
 
392
    long long len     = q->q_len;
 
393
    long long samples = q->q_len_samples;
397
394
 
398
395
    fifo_unlock (q);
399
396
 
413
410
    }
414
411
}
415
412
 
 
413
void gu_fifo_stats_flush(gu_fifo_t* q)
 
414
{
 
415
    fifo_lock (q);
 
416
 
 
417
    q->q_len = 0;
 
418
    q->q_len_samples = 0;
 
419
 
 
420
    fifo_unlock (q);
 
421
}
 
422
 
416
423
/* destructor - would block until all members are dequeued */
417
424
void gu_fifo_destroy   (gu_fifo_t *queue)
418
425
{
468
475
              "\tlength  = %lu\n"
469
476
              "\trows    = %lu\n"
470
477
              "\tcolumns = %lu\n"
471
 
              "\tused    = %lu (%lu bytes)\n"
 
478
              "\tused    = %u (%zu bytes)\n"
472
479
              "\talloctd = %lu bytes\n"
473
480
              "\thead    = %lu, tail = %lu\n"
474
481
              "\tavg.len = %f"
478
485
              queue->length,
479
486
              queue->rows_num,
480
487
              queue->col_mask + 1,
481
 
              queue->used, queue->used * queue->item_size,
 
488
              queue->used, (size_t)queue->used * queue->item_size,
482
489
              queue->alloc,
483
490
              queue->head, queue->tail,
484
491
              queue->q_len_samples > 0 ?