Raxol.Terminal.Buffer.EnhancedManager (Raxol v0.5.0)

View Source

Enhanced buffer manager with advanced features for improved performance.

This module provides:

  • Asynchronous buffer updates
  • Buffer compression
  • Buffer pooling
  • Performance optimization

Features

  • Async updates for non-blocking operations
  • Compression to reduce memory usage
  • Buffer pooling for efficient memory management
  • Performance monitoring and optimization

Summary

Functions

Compresses the buffer to reduce memory usage.

Gets a buffer from the pool or creates a new one.

Gets the current performance metrics.

Creates a new enhanced buffer manager.

Optimizes the buffer manager based on current performance metrics.

Processes all queued updates.

Queues an asynchronous buffer update.

Returns a buffer to the pool.

Types

t()

@type t() :: %Raxol.Terminal.Buffer.EnhancedManager{
  buffer: Raxol.Terminal.ScreenBuffer.t(),
  compression_state: map(),
  performance_metrics: map(),
  pool: map(),
  update_queue: :queue.queue()
}

Functions

compress_buffer(manager, opts \\ [])

@spec compress_buffer(
  t(),
  keyword()
) :: t()

Compresses the buffer to reduce memory usage.

Parameters

  • manager - The buffer manager instance
  • opts - Compression options

Returns

Updated buffer manager instance

get_buffer(manager, width, height)

@spec get_buffer(t(), non_neg_integer(), non_neg_integer()) ::
  {Raxol.Terminal.ScreenBuffer.t(), t()}

Gets a buffer from the pool or creates a new one.

Parameters

  • manager - The buffer manager instance
  • width - The width of the buffer
  • height - The height of the buffer

Returns

{buffer, updated_manager}

get_performance_metrics(manager)

@spec get_performance_metrics(t()) :: map()

Gets the current performance metrics.

Parameters

  • manager - The buffer manager instance

Returns

Map containing performance metrics

new(width, height, opts \\ [])

@spec new(non_neg_integer(), non_neg_integer(), keyword()) :: t()

Creates a new enhanced buffer manager.

Parameters

  • width - The width of the buffer
  • height - The height of the buffer
  • opts - Additional options

Returns

A new enhanced buffer manager instance

optimize(manager)

@spec optimize(t()) :: t()

Optimizes the buffer manager based on current performance metrics.

Parameters

  • manager - The buffer manager instance

Returns

Updated buffer manager instance

process_updates(manager)

@spec process_updates(t()) :: t()

Processes all queued updates.

Parameters

  • manager - The buffer manager instance

Returns

Updated buffer manager instance

queue_update(manager, update_fn)

@spec queue_update(t(), (Raxol.Terminal.ScreenBuffer.t() ->
                     Raxol.Terminal.ScreenBuffer.t())) :: t()

Queues an asynchronous buffer update.

Parameters

  • manager - The buffer manager instance
  • update_fn - The function to execute for the update

Returns

Updated buffer manager instance

return_buffer(manager, buffer)

@spec return_buffer(t(), Raxol.Terminal.ScreenBuffer.t()) :: t()

Returns a buffer to the pool.

Parameters

  • manager - The buffer manager instance
  • buffer - The buffer to return

Returns

Updated buffer manager instance