PxOpoolRequest()
Create an object pool object.
- APPLIES TO
-
8.2.0
- SYNOPSIS
-
PxOpool_t PxOpoolRequest (PxOpoolType_t opooltype, PxUInt_t capacity, PxOpool_t src, PxOpool_t OpoolId); - ARGUMENTS
|
|
|
|
|
|
|
- RETURN VALUES
-
-
Valid object pool handle on success
-
Invalid object pool handle on failure
-
- ERROR CODES
-
PXERR_OPOOL_ILLOPOOLOpoolIdorsrcis not a valid pool objectPXERR_ACCESS_RIGHTThe calling task has not the right to access the object pool
PXERR_GLOBAL_ILLEGAL_COREThe requested object pool is not on the same core
PXERR_OPOOL_ILLTYPEIllegal object pool type
PXERR_OPOOL_ILLCAPACITYInsufficient capacity in the source object pool
PXERR_OPOOL_ILLSRCThe source of a real object pool must be real
PXERR_OBJ_ABORTEDThe request was aborted by an event
PXERR_OBJ_NOOBJNo free object is available
PXERR_OBJ_ILLOBJThe passed object handle is not valid
PXERR_INTERNAL_INCONSISTENCYInconsistency of internal structures
- DESCRIPTION
-
PxOpoolRequestfunction creates an object pool object of typeopooltypeby converting a generic object from object poolOpoolId. The new object handle is returned. If there is no object available,PxOpoolRequestwaits until a free object is available.The object pool can be of type:
-
PXOpoolReal -
PXOpoolVirtual
When creating a new object pool of type
PXOpoolReal, the number of free objects in parent object pool is reduced in favor of a newly created object pool. The newPXOpoolRealobject pool can be used for reserving the required number of objects for critical tasks.When creating a new object pool of type
PXOpoolVirtual, the newly created object pool still shares the objects with the parent object pool, but the capacity parameter defines the maximum number of consumed objects. The newPXOpoolVirtualobject pool can be used to limit the number of object consumed by a task. -
- IMPLEMENTATION GUIDELINES
-
- Before call
-
-
opooltypemust be of typePxOpoolType_tand may have one of the following values-
PXOpoolReal -
PXOpoolVirtual
-
-
capacityshould be a plausible value held in a variable (C) or in a constant (V). -
srcandOpoolIdmust be valid PXROS-HR object pools and the calling task must have the access right to take objects from them. The validity ofsrcandOpoolIdmay also be checked by thePxOpoolIsValidmacro (F). The object pool must be created on the same core as the caller runs on. The creator core id can be read with the macroPxOpoolCoreIdand the own core id withPxGetCoreId(C). Typically the task’s default object poolPXOpoolTaskdefaultis used for this purpose.
-
- After call
-
-
The returned value is the id of type
PxOpool_t. This id may be checked with one of the following macros:-
PxOpoolIdIsValid()must be true. -
PxOpoolIdGet()must not be_PXIllegalObjId. -
PxOpoolIdError()must bePXERR_NOERRORotherwise the returned error code has to be interpreted (C).
-
-
- Best Practice
-
-
PxOpoolRequestmay block, if no PXROS-HR object is available. If blocking calls are prohibited,PxOpoolRequest_NoWaitshould be used instead. -
PxOpoolRequestshould only be called during initialization to ensure the availability of the object pool.
-
- SEE ALSO
- USAGE
-
#include "pxdef.h" PxOpool_t Opool = PxOpoolRequest(PXOpoolVirtual, 1, PXOpoolTaskdefault, OpoolId); if (PxOpoolIdError(Opool) != PXERR_NOERROR) { // Report error }