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_ILLOPOOL
OpoolId
or src is not a valid pool objectPXERR_ACCESS_RIGHT
The calling task has not the right to access the object pool
PXERR_GLOBAL_ILLEGAL_CORE
The requested object pool is not on the same core
PXERR_OPOOL_ILLTYPE
Illegal object pool type
PXERR_OPOOL_ILLCAPACITY
Insufficient capacity in the source object pool
PXERR_OPOOL_ILLSRC
The source of a real object pool must be real
PXERR_OBJ_ABORTED
The request was aborted by an event
PXERR_OBJ_NOOBJ
No free object is available
PXERR_OBJ_ILLOBJ
The passed object handle is not valid
PXERR_INTERNAL_INCONSISTENCY
Inconsistency of internal structures
- DESCRIPTION
-
PxOpoolRequest function creates an object pool object of type opooltype by converting a generic object from object pool OpoolId. The new object handle is returned. If there is no object available, PxOpoolRequest waits 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 favour of a newly created object pool. The new PXOpoolReal object 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 new PXOpoolVirtual object pool can be used to limit the number of object consumed by a task.
-
- IMPLEMENTATION GUIDELINES
-
- Before call
-
-
opooltype
must be of typePxOpoolType_t
and may have one of the following values-
PXOpoolReal
-
PXOpoolVirtual
-
-
capacity
should be a plausible value held in a variable (C) or in a constant (V). -
src
andOpoolId
must be valid PXROS-HR object pools and the calling task must have the access right to take objects from them. The validity ofsrc
andOpoolId
may also be checked by thePxOpoolIsValid
macro (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 macroPxOpoolCoreId
and the own core id withPxGetCoreId
(C). Typically the task’s default object poolPXOpoolTaskdefault
is 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_NOERROR
otherwise the returned error code has to be interpreted (C).
-
-
- Best Practice
-
-
PxOpoolRequest
may block, if no PXROS-HR object is available. If blocking calls are prohibited,PxOpoolRequest_NoWait
should be used instead. -
PxOpoolRequest
should 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 }