User`s guide

Cray XMT Programming Environment Users Guide
result = clientEndpoint->remoteCallSync(serverID,
QUERY_ENGINE, FUNC_QUERY1,
inbuf, INBUF_SIZE, outbuf, &outDatLen);
if(result == LUC_ERR_OK)
// The RPC was successful.
// outDataLen contains the size of data returned in outbuf.
else if result < LUC_ERR_MAX)
{
// Result contains a LUC error code.
}
else
{
// Result is the return value from remote function
}
clientEndpoint->stopService();
delete clientEndpoint;
}
5.3 Creating and Using a LUC Server
The server allocates and activates an endpoint object in a manner similar to that of
the client. Object deactivation and deletion are also similar. The primary difference
is the requirement for the server to register its remote functions. Use the following
steps to create a server object.
Procedure 4. Creating and using a LUC server object
1. Include the header file <luc/luc_exported.h>, as well as the application
defined header file.
2. Declare a pointer to a LucEndpoint object.
3. Allocate the object by calling luc_allocate_endpoint.
4. Call registerRemoteCall to register each function that will be serviced by
this endpoint. The first parameter is the service type, the second parameter is the
function index, and the third parameter is the address of the function.
5. Activate the server endpoint by calling startService. The parameter is the
number of LUC worker threads to start. The default is 1. The MTK version of
the library ignores this value and creates one worker thread for each RPC. This
method call causes LUC to allocate a number of nearby memory buffers for
incoming requests and pre-post these receive buffers with the Fast I/O driver. The
worker threads service the client requests as they come in.
6. Wait for a request to halt the service. There are many ways to accomplish this.
In the following MTK example, the main application server thread then waits to
be told to halt the service by doing a synchronized read on an empty memory
location. When the request is received, the application stops the service and
deletes the endpoint. The application coordinates the notification to the server to
56 S247920