bitset: add bitset_stream_size and bitset_stream_queued_bytes

This commit is contained in:
nick
2013-09-12 16:54:42 +01:00
parent 0a029fbbf5
commit c3a5eb0600
2 changed files with 80 additions and 5 deletions

View File

@@ -261,6 +261,38 @@ static inline void bitset_stream_dequeue(
return;
}
static inline int bitset_stream_size( struct bitset_mapping * set )
{
int size;
pthread_mutex_lock( &set->stream->mutex );
size = set->stream->size;
pthread_mutex_unlock( &set->stream->mutex );
return size;
}
static inline uint64_t bitset_stream_queued_bytes(
struct bitset_mapping * set,
enum bitset_stream_events event
)
{
uint64_t total = 0;
int i;
pthread_mutex_lock( &set->stream->mutex );
for ( i = set->stream->out; i < set->stream->in ; i++ ) {
if ( set->stream->entries[i].event == event ) {
total += set->stream->entries[i].len;
}
}
pthread_mutex_unlock( &set->stream->mutex );
return total;
}
static inline void bitset_stream_on( struct bitset_mapping * set )
{
BITSET_LOCK;