Blender V5.0
gsqueue.cc File Reference

A generic structure queue (a queue for fixed length generally small) structures. More...

#include <cstring>
#include "MEM_guardedalloc.h"
#include "BLI_gsqueue.h"
#include "BLI_utildefines.h"
#include "BLI_strict_flags.h"

Go to the source code of this file.

Classes

struct  QueueChunk
struct  _GSQueue

Macros

#define CHUNK_SIZE_DEFAULT   (1 << 16)
#define CHUNK_ELEM_MIN   32

Functions

static void * queue_get_first_elem (GSQueue *queue)
static void * queue_get_last_elem (GSQueue *queue)
static size_t queue_chunk_elem_max_calc (const size_t elem_size, size_t chunk_size)
GSQueueBLI_gsqueue_new (const size_t elem_size)
static void queue_free_chunk (QueueChunk *data)
void BLI_gsqueue_free (GSQueue *queue)
void BLI_gsqueue_push (GSQueue *queue, const void *item)
void BLI_gsqueue_pop (GSQueue *queue, void *r_item)
size_t BLI_gsqueue_len (const GSQueue *queue)
bool BLI_gsqueue_is_empty (const GSQueue *queue)

Detailed Description

A generic structure queue (a queue for fixed length generally small) structures.

Definition in file gsqueue.cc.

Macro Definition Documentation

◆ CHUNK_ELEM_MIN

#define CHUNK_ELEM_MIN   32

Definition at line 24 of file gsqueue.cc.

Referenced by queue_chunk_elem_max_calc(), and stack_chunk_elem_max_calc().

◆ CHUNK_SIZE_DEFAULT

#define CHUNK_SIZE_DEFAULT   (1 << 16)

Definition at line 22 of file gsqueue.cc.

Referenced by BLI_gsqueue_new(), and BLI_stack_new().

Function Documentation

◆ BLI_gsqueue_free()

void BLI_gsqueue_free ( GSQueue * queue)

◆ BLI_gsqueue_is_empty()

bool BLI_gsqueue_is_empty ( const GSQueue * queue)

Returns true if the queue is empty, false otherwise.

Definition at line 163 of file gsqueue.cc.

References _GSQueue::chunk_first.

Referenced by BLI_gsqueue_pop(), unsubdivide_face_center_vertex_tag(), unsubdivide_init_elem_ids(), and unsubdivide_tag_disconnected_mesh_element().

◆ BLI_gsqueue_len()

size_t BLI_gsqueue_len ( const GSQueue * queue)

Definition at line 158 of file gsqueue.cc.

References _GSQueue::elem_num.

◆ BLI_gsqueue_new()

◆ BLI_gsqueue_pop()

void BLI_gsqueue_pop ( GSQueue * queue,
void * r_item )

Retrieves and removes the first element from the queue. The value is copies to r_item, which must be at least elem_size bytes.

Does not reduce amount of allocated memory.

Definition at line 135 of file gsqueue.cc.

References BLI_assert, BLI_gsqueue_is_empty(), _GSQueue::chunk_elem_max, _GSQueue::chunk_first, _GSQueue::chunk_first_index, _GSQueue::chunk_free, _GSQueue::chunk_last, _GSQueue::chunk_last_index, _GSQueue::elem_num, _GSQueue::elem_size, QueueChunk::next, queue_get_first_elem(), and UNLIKELY.

Referenced by unsubdivide_face_center_vertex_tag(), unsubdivide_init_elem_ids(), and unsubdivide_tag_disconnected_mesh_element().

◆ BLI_gsqueue_push()

void BLI_gsqueue_push ( GSQueue * queue,
const void * item )

Copies the source value onto the end of the queue

Note
This copies GSQueue.elem_size bytes from item, (the pointer itself is not stored).
Parameters
itemsource data to be copied to the queue.

Definition at line 100 of file gsqueue.cc.

References BLI_assert, _GSQueue::chunk_elem_max, _GSQueue::chunk_first, _GSQueue::chunk_free, _GSQueue::chunk_last, _GSQueue::chunk_last_index, _GSQueue::elem_num, _GSQueue::elem_size, MEM_mallocN(), QueueChunk::next, queue_get_last_elem(), and UNLIKELY.

Referenced by unsubdivide_face_center_vertex_tag(), unsubdivide_init_elem_ids(), and unsubdivide_tag_disconnected_mesh_element().

◆ queue_chunk_elem_max_calc()

size_t queue_chunk_elem_max_calc ( const size_t elem_size,
size_t chunk_size )
static
Returns
number of elements per chunk, optimized for slop-space.

Definition at line 55 of file gsqueue.cc.

References BLI_assert, CHUNK_ELEM_MIN, MEM_SIZE_OVERHEAD, and UNLIKELY.

Referenced by BLI_gsqueue_new().

◆ queue_free_chunk()

void queue_free_chunk ( QueueChunk * data)
static

Definition at line 84 of file gsqueue.cc.

References data, and MEM_freeN().

Referenced by BLI_gsqueue_free().

◆ queue_get_first_elem()

void * queue_get_first_elem ( GSQueue * queue)
static

Definition at line 42 of file gsqueue.cc.

Referenced by BLI_gsqueue_pop().

◆ queue_get_last_elem()

void * queue_get_last_elem ( GSQueue * queue)
static

Definition at line 47 of file gsqueue.cc.

Referenced by BLI_gsqueue_push().