Let's look at the internal implementation of sigslot. H. Take the relatively simple signal1 as an example. It can have one parameter. One of the two template parameters is a parameter type, and the other is a multithreading policy.
Focuses on its
1) connect the Connect Method to the target class and target method
2) emit method, corresponding method for sending trigger messages to the slot
Template <class arg1_type, class mt_policy = role> class signal1: Public _ signal_base1 <arg1_type, mt_policy> {public: typedef _ signal_base1 <arg1_type, mt_policy> base; typedef typename base :: connections_list; using base: m_connected_slots; signal1 () {;} signal1 (const signal1 <arg1_type, mt_policy> & S): _ signal_base1 <arg1_type, mt_policy> (s) {;} template <class desttype> voi D connect (desttype * Pclass, void (desttype: * pmemfun) (arg1_type) {lock_block <mt_policy> lock (this); _ connection1 <desttype, arg1_type, mt_policy> * conn = new _ connection1 <desttype, arg1_type, mt_policy> (Pclass, pmemfun); m_connected_slots.push_back (conn); Pclass-> signal_connect (this );} void emit (arg1_type A1) {lock_block <mt_policy> lock (this); typename connections_list: const_iterator itnext, it = m_conn Ected_slots.begin (); typename connections_list: const_iterator itend = m_connected_slots.end (); While (it! = Itend) {itnext = it; ++ itnext; (* It)-> emit (A1); It = itnext ;}} void operator () (arg1_type A1) {lock_block <mt_policy> lock (this); typename connections_list: const_iterator itnext, it = upper (); typename connections_list: const_iterator itend = lower (); While (it! = Itend) {itnext = it; ++ itnext; (* It)-> emit (A1); It = itnext ;}}};
... To be continued...