LineGridCanvasPanel 2.3: The Widget Pool System
The pool sytem is exposed through API endpoints. It does not automatically rewrite every child workflow by itself. The base class gives future SpawnInViewWidgets() / RemoveOutOfViewWidgets() implementations a clean way to opt into pooling.
With bUseWidgetPool = true:
AcquireChildWidgetFromPool(Class, DataObject) does this:
- Checks
ObjectToSmartChildWidgetMapfirst. - If that
DataObjectalready has an active widget, returns it. - Otherwise checks the pool bucket for the exact widget class.
- If a pooled widget exists, reuses it.
- If not, calls
CreateWidget. - Calls
SetDataObject(DataObject)before registration. - Calls the child acquire hook.
- Calls
AddAndRegisterSmartWidget. - Requests child layout refresh.
ReleaseChildWidgetToPool(Child) does this:
- Verifies the child is actively registered under its current
GetDataObject(). - Calls
DeRegisterSmartChild, removing it from the canvas andObjectToSmartChildWidgetMap. - Calls the child release hook.
- Clears the data object with
SetDataObject(nullptr). - Stores it in the exact class bucket only if that bucket is below its max.
- If the bucket is full, the widget is dropped and can be garbage collected.
With bUseWidgetPool = false:
You can still call the same API, but it behaves like a non-retaining lifecycle.
AcquireChildWidgetFromPool(...) still:
- checks the active map first,
- then creates a widget if needed.
But it does not reuse inactive pooled widgets.
ReleaseChildWidgetToPool(...) still:
- deregisters safely,
- clears the data object,
- calls the child release hook,
but it does not store the widget for reuse.
So if someone does not want pooling, they can either:
- set
bUseWidgetPool = falseand still use the same acquire/release API, or - ignore the pool API completely and use
CreateWidget,AddAndRegisterSmartWidget, andDeRegisterSmartChildmanually.
The intended pooled virtualization pattern is:
RemoveOutOfViewWidgets(...)
{
// For active children no longer in view:
ReleaseChildWidgetToPool(Child);
}
SpawnInViewWidgets(...)
{
// For data objects now in view:
if (!GetActiveLineGridChildWidgetForDataObject(DataObject))
{
Child = AcquireChildWidgetFromPool(WidgetClass, DataObject);
// configure logical spans / visuals
}
}