...
To avoid garbage for embedded messages entities when using Xbuf encoding, while still providing a mechanism for applications to hold such fields in state beyond the lifespan of the message from whence they came, additional take/lend accessors are generated for embedded entity fields. Considerations for using embedded entity fields in the context of message pooling are discussed in detail in the section Embedded Entities.
Code Block | ||||
---|---|---|---|---|
| ||||
@Generated(value="com.neeve.adm.AdmGenerator", date="Fri Jan 23 02:03:22 PST 2015") public interface IMyMessage extends extends IRogNode, IRogMessage { final public void setChildField(final Child2 val); final public Child2 getChildField(); final public void lendChildField(final Child2 val); final public Child2 takeChildField();} |
...
- The field or type element that defines it has a poolable="true" attribute. The String type will be created based on the name of the field.
- A semantic type is defined with a base type of string and the poolable attribute set to true. The String type will be based on the name of the type.
- For applications that would rather separate the notion of pooling from the model itself, the Code Generator can be run with a directive indicating that all String fields should generate a poolable type (see Directives in the sections below).
- In the future, different narrower directives may be introduced for finer-grained control over what String fields will create poolable types.
...
- Preallocate the pooled string type with preallocated application state, and copy the string from the inbound message into domain state. In this approach, the message keeps its reference to the pooled string field and reuses the same reference when the message is recycled through its pool.
- Use take/lend semantics in the same fashion as with a Nested Entity as described in Xbuf and Embedded Entities. The domain state needn't preallocate the pooled string type but rather takes if from the message which then draws a new instance from a globally configured preallocated when the message itself is recycled to its pool.
...
Code Block | ||
---|---|---|
| ||
<collections> <collection name="MyQueue" is="Queue" contains="MyEntity" factoryid="1" id="5" /> <collection name="MySet" is="Set" contains="MyEntity" factoryid="1" id="6" /> <collection name="MyLongMap" contains="MyEntity" is="LongMap" factoryid="1" id="76" /> </collections> <entity name="MyEntity" factoryid="1" id="1"> <field name="longKey" type="Long" isKey="true" id="1"/> <field name="aQueue" type="MyQueue" id="2"/> <field name="aMap" type="MyStringMap id="3"/> </entity> |
...