3.2. Data blocks

Data blocks represents a large block of data. Some resources use a data block as a source of data. The same data block may be used together with many resources.

RenDataBlock* ren_data_block_new( ren_size size,
  RenUsage usage);
 

Define a new data block. The data will be internally allocated, with the size as specified. The parameter usage specifies how often the data block is intended to be used and modified, which may allow the implementation to be more efficient.

RenUsage

REN_USAGE_DONT_CARE

Let backend choose a generally good solution. Not recommended.

REN_USAGE_IMMUTABLE

Data cannot be changed and thus never is changed.

REN_USAGE_STATIC

Data is modified very seldom or never, and used many times.

REN_USAGE_DYNAMIC

Data is modified often, but also used many times between modifications.

REN_USAGE_STREAM

Data is modified almost as often as it is used.

RenDataBlock* ren_data_block_ref( RenDataBlock* data_block);
 

Increases the reference count of the DataBlock instance and then returns it.

void ren_data_block_unref( RenDataBlock* data_block);
 

Decreases the reference count of the DataBlock instance. When its reference count drops to 0, it will be destroyed automatically.

void* ren_data_block_begin_edit( RenDataBlock* data_block);
 

Get the internal data of the data block with the intention of modifying it. This function may lock while some other thread is already using the data.

void ren_data_block_end_edit( RenDataBlock* data_block);
 

Mark an end of modifying the internal data. The pointer received with ren_data block_begin_edit must not be used anymore.

void ren_data_block_changed( RenDataBlock* data_block,
  ren_size from,
  ren_size count);
 

Notify that a part of the data has been changed. This is done between ren_data_block_begin_edit and ren_data_block_end_edit. The parameter count may be 0 to denote everything to the end.