# Revision history [back]

### when is the callback function called

Hi all,

I am slightly confused about when the callback functions are called from ROS Subscriber. Taking the following code as example:

#include "ros/ros.h"
#include <geometry_msgs/Vector3.h>

void callback_fn(const geometry_msgs::Vector3::ConstPtr& ticks)
{
}

int main(int argc, char **argv)
{
ros::init(argc,argv,"test");
ros::NodeHandle n;
ros::Subscriber re_msg = n.subscribe("re_ticks",1000,callback_fn);
ros::spin();
}


So my question is whenever ros::spin() is called, does it call all the callback functions or only those for which the value of the message on the corresponding topic has changed? So in the above example, Is callback_fn called every time ros::spin() is executed or only when the message on the topic "re_ticks" has changed?