All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Macros | Typedefs | Functions
Turbulence Context: API provided to handle Turbulence contexts

Macros

#define TBC_VORTEX_CTX(_tbc_ctx)   (turbulence_ctx_get_vortex_ctx (_tbc_ctx))
 
#define VORTEX_TBC_CTX(_vortex_ctx)   (vortex_ctx_get_data (_vortex_ctx, "tbc:ctx"))
 

Typedefs

typedef struct _TurbulenceCtx TurbulenceCtx
 

Functions

void turbulence_ctx_free (TurbulenceCtx *ctx)
 
axlPointer turbulence_ctx_get_data (TurbulenceCtx *ctx, const char *key)
 
VortexCtx * turbulence_ctx_get_vortex_ctx (TurbulenceCtx *ctx)
 
axl_bool turbulence_ctx_is_child (TurbulenceCtx *ctx)
 
TurbulenceCtxturbulence_ctx_new ()
 
void turbulence_ctx_set_data (TurbulenceCtx *ctx, const char *key, axlPointer data)
 
void turbulence_ctx_set_data_full (TurbulenceCtx *ctx, const char *key, axlPointer data, axlDestroyFunc key_destroy, axlDestroyFunc data_destroy)
 
void turbulence_ctx_set_vortex_ctx (TurbulenceCtx *ctx, VortexCtx *vortex_ctx)
 
void turbulence_ctx_wait (TurbulenceCtx *ctx, long microseconds)
 

Detailed Description

Macro Definition Documentation

#define TBC_VORTEX_CTX (   _tbc_ctx)    (turbulence_ctx_get_vortex_ctx (_tbc_ctx))

Allows to get the vortex context associated to the turbulence context provided.

Parameters
_tbc_ctxThe turbulence context which is required to return the vortex context associated.
Returns
A reference to the vortex context associated.

Referenced by turbulence_run_config(), and turbulence_support_smtp_send().

#define VORTEX_TBC_CTX (   _vortex_ctx)    (vortex_ctx_get_data (_vortex_ctx, "tbc:ctx"))

As oposse to TBC_VORTEX_CTX, this macro returns the TurbulenceCtx object associated to the VortexCtx object.

Parameters
_vortex_ctxThe vortex context (VortexCtx) which is required to return the turbulence context associated.
Returns
A reference to the turbulence context associated (TurbulenceCtx).

Typedef Documentation

typedef struct _TurbulenceCtx TurbulenceCtx

Turbulence execution context.

Function Documentation

void turbulence_ctx_free ( TurbulenceCtx ctx)

Deallocates the turbulence context provided.

Parameters
ctxThe context reference to terminate.

References error, msg, and turbulence_module_cleanup().

Referenced by turbulence_exit().

axlPointer turbulence_ctx_get_data ( TurbulenceCtx ctx,
const char *  key 
)

Allows to retrieve data stored by turbulence_ctx_set_data and turbulence_ctx_set_data_full.

Parameters
ctxThe TurbulenceCtx where the retrieve operation will be performed.
keyThe key that index the data to be returned.
Returns
A reference to the data or NULL if nothing was found. The function also returns NULL if a NULL ctx is received.
VortexCtx * turbulence_ctx_get_vortex_ctx ( TurbulenceCtx ctx)

Allows to get the TurbulenceCtx associated to the vortex.

Parameters
ctxThe turbulence context where it is expected to find a Vortex context (VortexCtx).
Returns
A reference to the VortexCtx.

Referenced by turbulence_exit(), and turbulence_run_config().

axl_bool turbulence_ctx_is_child ( TurbulenceCtx ctx)

Allows to check if the provided turbulence ctx is associated to a child process.

This function can be used to check if the current execution context is bound to a child process which means we are running in a child process

Returns
axl_false when contexts is representing master process otherwise axl_true is returned (child process). Keep in mind the function returns axl_false (master process) in the case or NULL reference received.
TurbulenceCtx * turbulence_ctx_new ( )

Allows to create a new turbulence context (an object used by the turbulence runtime to hold its current run time state).

The idea behind the turbulence initialization is to create a context object and the call to turbulence_init with that context object to create a new run-time. This function also calls to init the vortex context associated. You can get it with turbulence_ctx_get_vortex_ctx.

Once required to finish the context created a call to turbulence_exit is required, followed by a call to turbulence_ctx_free.

Returns
A newly allocated reference to the Turbulence context created. This function is already called by the turbulence engine.
void turbulence_ctx_set_data ( TurbulenceCtx ctx,
const char *  key,
axlPointer  data 
)

Allows to configure user defined data indexed by the provided key, associated to the TurbulenceCtx.

Parameters
ctxThe TurbulenceCtx to configure with the provided data.
keyThe index string key under which the data will be retreived later using turbulence_ctx_get_data. The function do not support storing NULL keys.
dataThe user defined pointer to data to be stored. If NULL is provided the function will understand it as a removal request, calling to delete previously stored data indexed by the same key.
void turbulence_ctx_set_data_full ( TurbulenceCtx ctx,
const char *  key,
axlPointer  data,
axlDestroyFunc  key_destroy,
axlDestroyFunc  data_destroy 
)

Allows to configure user defined data indexed by the provided key, associated to the TurbulenceCtx, with optionals destroy handlers.

This function is quite similar to turbulence_ctx_set_data but it also provides support to configure a set of handlers to be called to terminate data associated once finished TurbulenceCtx.

Parameters
ctxThe TurbulenceCtx to configure with the provided data.
keyThe index string key under which the data will be retreived later using turbulence_ctx_get_data. The function do not support storing NULL keys.
dataThe user defined pointer to data to be stored. If NULL is provided the function will understand it as a removal request, calling to delete previously stored data indexed by the same key.
key_destroyOptional handler to destroy key stored.
data_destroyOptional handler to destroy value stored.
void turbulence_ctx_set_vortex_ctx ( TurbulenceCtx ctx,
VortexCtx *  vortex_ctx 
)

Allows to configure the vortex context (VortexCtx) associated to the provided TurbulenceCtx.

Parameters
ctxTurbulenceCtx to be configured.
vortex_ctxVortex context to be configured.

Referenced by turbulence_init().

void turbulence_ctx_wait ( TurbulenceCtx ctx,
long  microseconds 
)

Allows to implement a microseconds blocking wait.

Parameters
ctxThe context where the wait will be implemented.
microsecondsBlocks the caller during the value provided. 1.000.000 = 1 second.

If ctx is NULL or microseconds <= 0, the function returns inmediately.

References msg2.