roscpp service calls - multithreading
I have a service created in C++ that only handles one request at a time. Normally this would not be a problem, but my service is computing a Descartes trajectory, which takes somewhere between 3-8 seconds. Is there a way to thread the service requests such that they are taking place at the same time instead of one after the other?
Here is the current implementation of my service.
int main(int argc, char **argv)
{
// Initialize node
ros::init(argc, argv, "compute_descartes_traj_server");
ros::NodeHandle node_handle;
// Create subscriber to /joint_states topic
Listener listener;
ros::Subscriber sub = node_handle.subscribe("joint_states", 10, &Listener::jointStatesCallback, &listener);
// Create ComputeDescartesTraj service
ros::ServiceServer service = node_handle.advertiseService("compute_descartes_traj", &Listener::ComputeDescartesTraj, &listener);
ROS_INFO("-----------------------------------------------");
ROS_INFO("Ready to compute Descartes trajectory.");
ROS_INFO("-----------------------------------------------");
// Keep ROS service running until it is shutdown
ros::spin();
return 0;
}