wxMaxima
Loading...
Searching...
No Matches
Data Structures | Public Member Functions | Static Public Attributes
MaximaItemQueue Class Reference

Items Maxima sent, on their way from the socket thread to the GUI thread. More...

#include <MaximaItemQueue.h>

Data Structures

struct  Item
 One piece of Maxima's output: what it is, and its text. More...
 

Public Member Functions

 MaximaItemQueue (int mergeableCause, std::size_t backPressureChars=DefaultBackPressureChars)
 
bool Push (std::vector< Item > &&items)
 Appends items.
 
bool Take (Item &item)
 Takes the oldest item, merged with the mergeable items that follow it.
 
bool Empty () const
 Whether nothing is waiting.
 
std::size_t QueuedChars () const
 The number of characters waiting.
 
bool BackPressure () const
 Whether the socket thread should stop reading until the GUI caught up.
 
void Clear ()
 Drops everything that waits.
 

Static Public Attributes

static constexpr std::size_t DefaultBackPressureChars = 64 * 1024
 The default for how much output may wait.
 

Detailed Description

Items Maxima sent, on their way from the socket thread to the GUI thread.

Push() is called from the socket thread, everything else from the GUI thread; BackPressure() is safe from either.

Constructor & Destructor Documentation

◆ MaximaItemQueue()

MaximaItemQueue::MaximaItemQueue ( int  mergeableCause,
std::size_t  backPressureChars = DefaultBackPressureChars 
)
inlineexplicit
Parameters
mergeableCauseConsecutive items of this kind are handed out as one (plain text that only got split because it arrived in pieces).
backPressureCharsHow many characters may wait before the socket thread should stop reading.

Member Function Documentation

◆ Push()

bool MaximaItemQueue::Push ( std::vector< Item > &&  items)

Appends items.

Called by the socket thread.

Returns
true if the consumer has to be told that there is something to take: that is the case only if it found the queue empty last time it looked, and hasn't been told since.

◆ Take()

bool MaximaItemQueue::Take ( Item &  item)

Takes the oldest item, merged with the mergeable items that follow it.

Returns
false if there was nothing to take. From then on the next Push() asks for a notification again.

Field Documentation

◆ DefaultBackPressureChars

constexpr std::size_t MaximaItemQueue::DefaultBackPressureChars = 64 * 1024
staticconstexpr

The default for how much output may wait.

Enough for a GUI turn's worth of output even of the fastest flood seen (disp() in a loop, about 40 characters a line), and little enough that what is left to display after the user pressed Ctrl+G takes seconds, not minutes. A single item larger than this (a huge matrix) still gets through: the limit only stops the socket thread from reading more.


The documentation for this class was generated from the following files: