Apama 10.3 | Apama Documentation | Developing Apama Applications | Developing EPL Plug-ins | EPL Plug-ins in C and C++ Written Prior to 10.0 | Advanced plug-in functionality in C++ and C | Writing EPL plug-ins for parallel processing applications
Writing EPL plug-ins for parallel processing applications
When multiple contexts need to concurrently use a plug-in, you must ensure that the plug-in is thread safe. A plug-in can export a function that returns the capabilities of the plug-in. See the AP_PluginCommon.h header file in the include directory of your Apama installation for the definition of AP_PLUGIN_GET_CAPABILITIES_FUNCTION_NAME. The correlator calls this function before it calls the plug-in's init() function. The return value is a bit-wise OR of capabilities, as defined in the AP_PluginCommon.h header file. If the return value indicates that the plug-in is thread-safe, multiple contexts can make concurrent calls to the plug-in. When multiple contexts need to concurrently use a plug-in, you must ensure that the plug-in is thread-safe.
A plug-in can use a context's ID to send events to a particular context. Use the AP_Context.getContextId() method to obtain the context ID. The correlator passes an AP_Context object to each plug-in. This object has a getCorrelator() method that returns an interface that defines a sendEventTo() method, which has the following signature:
sendEventTo(const char *event, AP_uint64 targetContextId,
const AP_Context &source)
The sendEventTo() method takes three arguments:
*event — For the event to send, specify a string in the format described in Event file format.
*targetContextId — Specify the ID of the context you want to send the event to.
*&source — Specify the context that this plug-in call is running in. This is the AP_Context object that was passed to the plug-in method or event handler method. If this method is called from a background thread then that thread passes an AP_Context::NoContext() object to this method. Specify that object as the source context.
You can obtain the current context ID with a call to AP_Context.getContextId(), which might be useful for sending or passing events to other threads. However, you should not use the returned object as the value for the &source argument.
The following overloading of the sendEventTo() method is deprecated and will be removed in a future release. Use the previously described overloading instead.
sendEventTo(const char *event, AP_uint64 targetContextId,
AP_uint64 sourceContextId)
Note: The class AP_Context, which you use for EPL plug-in development, is completely different and unrelated to contexts that you define in EPL for parallel processing.

Copyright © 2013-2018 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.