bps_set_domain_data()

Sets domain specific data for the active channel.

Synopsis:

#include <bps/bps.h>
 
BPS_API int bps_set_domain_data(int domain_id, void *new_data, void **old_data)

Arguments:

domain_id
The domain ID to associate new_data with.
new_data
The service user data that should be stored in the active channel.
old_data
If a value of NULL is not provided, it is set to the previous data for the domain_id parameter.

Library:

libbps

Description:

Call the function when a service wants to set specific user data for the active channel. Often, a service has data that is particular to a channel. Since each service needs to call the bps_register_domain() function to create events, the same domain ID is used for a service to reference its data. The specifics of the type of data to store, however, is dependent on the implementation of each service.

At minimum, most services pass a structure that contains a file descriptor. In most cases, this is the same file descriptor that was added using the bps_add_fd() function.

Channels are thread-specific and a channel on one thread cannot be used by another thread. In addition, only active channels can retrieve data.

To clear domain data from the channel, call this function with the new_data parameter set to a value of NULL.

If old_data is not a NULL value, it is set to the previous data that was associated with same value of the domain_id parameter. If no data was previously set, it is set to a value of NULL.

Returns:

BPS_SUCCESS if the file descriptor was successfully removed from the channel, BPS_FAILURE with the errno value set otherwise.