Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: webrtc/base/sigslot.h

Issue 2842423002: Fixing sigslot copy constructors. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | webrtc/base/sigslot_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // sigslot.h: Signal/Slot classes 1 // sigslot.h: Signal/Slot classes
2 // 2 //
3 // Written by Sarah Thompson (sarah@telergy.com) 2002. 3 // Written by Sarah Thompson (sarah@telergy.com) 2002.
4 // 4 //
5 // License: Public domain. You are free to use this code however you like, with the proviso that 5 // License: Public domain. You are free to use this code however you like, with the proviso that
6 // the author takes on no responsibility or liability for any use. 6 // the author takes on no responsibility or liability for any use.
7 // 7 //
8 // QUICK DOCUMENTATION 8 // QUICK DOCUMENTATION
9 // 9 //
10 // (see also the full documentation at http://sigsl ot.sourceforge.net/) 10 // (see also the full documentation at http://sigsl ot.sourceforge.net/)
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 400
401 ~_signal_base() 401 ~_signal_base()
402 { 402 {
403 disconnect_all(); 403 disconnect_all();
404 } 404 }
405 405
406 private: 406 private:
407 _signal_base& operator= (_signal_base const& that); 407 _signal_base& operator= (_signal_base const& that);
408 408
409 public: 409 public:
410 » » _signal_base(const _signal_base& s) : _signal_base_interface(&_s ignal_base::do_slot_disconnect, &_signal_base::do_slot_duplicate) { 410 » » _signal_base(const _signal_base& o) : _signal_base_interface(&_s ignal_base::do_slot_disconnect, &_signal_base::do_slot_duplicate) {
411 lock_block<mt_policy> lock(this); 411 lock_block<mt_policy> lock(this);
412 » » » connections_list::const_iterator it = m_connected_slots. begin(); 412 for (const auto& connection : o.m_connected_slots)
413 » » » connections_list::const_iterator itEnd = m_connected_slo ts.end();
414 » » » while(it != itEnd)
415 { 413 {
416 » » » » it->getdest()->signal_connect(this); 414 » » » » connection.getdest()->signal_connect(this);
417 » » » » m_connected_slots.push_back(*it); 415 » » » » m_connected_slots.push_back(connection);
418 » » » » ++it;
419 } 416 }
420 } 417 }
421 418
422 bool is_empty() 419 bool is_empty()
423 { 420 {
424 lock_block<mt_policy> lock(this); 421 lock_block<mt_policy> lock(this);
425 return m_connected_slots.empty(); 422 return m_connected_slots.empty();
426 } 423 }
427 424
428 void disconnect_all() 425 void disconnect_all()
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 { 518 {
522 private: 519 private:
523 typedef std::set< _signal_base_interface* > sender_set; 520 typedef std::set< _signal_base_interface* > sender_set;
524 typedef sender_set::const_iterator const_iterator; 521 typedef sender_set::const_iterator const_iterator;
525 522
526 public: 523 public:
527 has_slots() : has_slots_interface(&has_slots::do_signal_connect, &has_slots::do_signal_disconnect, &has_slots::do_disconnect_all) 524 has_slots() : has_slots_interface(&has_slots::do_signal_connect, &has_slots::do_signal_disconnect, &has_slots::do_disconnect_all)
528 { 525 {
529 } 526 }
530 527
528 has_slots(has_slots const& o) : has_slots_interface(&has_slots:: do_signal_connect, &has_slots::do_signal_disconnect, &has_slots::do_disconnect_a ll)
529 {
Taylor Brandstetter 2017/04/27 03:08:44 I know indentation is messed up; I'm going to make
530 lock_block<mt_policy> lock(this);
531 for (auto* signal : o.m_senders) {
532 signal->slot_duplicate(&o, this);
533 }
534 }
535
531 ~has_slots() 536 ~has_slots()
532 { 537 {
533 this->disconnect_all(); 538 this->disconnect_all();
534 } 539 }
535 540
536 private: 541 private:
537 has_slots(has_slots const&);
538 has_slots& operator= (has_slots const&); 542 has_slots& operator= (has_slots const&);
539 543
540 static void do_signal_connect(has_slots_interface* p, _signal_ba se_interface* sender) 544 static void do_signal_connect(has_slots_interface* p, _signal_ba se_interface* sender)
541 { 545 {
542 has_slots* const self = static_cast< has_slots* >(p); 546 has_slots* const self = static_cast< has_slots* >(p);
543 lock_block<mt_policy> lock(self); 547 lock_block<mt_policy> lock(self);
544 self->m_senders.insert(sender); 548 self->m_senders.insert(sender);
545 } 549 }
546 550
547 static void do_signal_disconnect(has_slots_interface* p, _signal _base_interface* sender) 551 static void do_signal_disconnect(has_slots_interface* p, _signal _base_interface* sender)
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 655
652 template<typename A1, typename A2, typename A3, typename A4, typename A5 , typename A6, typename A7, typename mt_policy = SIGSLOT_DEFAULT_MT_POLICY> 656 template<typename A1, typename A2, typename A3, typename A4, typename A5 , typename A6, typename A7, typename mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
653 using signal7 = signal_with_thread_policy<mt_policy, A1, A2, A3, A4, A5, A6, A7>; 657 using signal7 = signal_with_thread_policy<mt_policy, A1, A2, A3, A4, A5, A6, A7>;
654 658
655 template<typename A1, typename A2, typename A3, typename A4, typename A5 , typename A6, typename A7, typename A8, typename mt_policy = SIGSLOT_DEFAULT_MT _POLICY> 659 template<typename A1, typename A2, typename A3, typename A4, typename A5 , typename A6, typename A7, typename A8, typename mt_policy = SIGSLOT_DEFAULT_MT _POLICY>
656 using signal8 = signal_with_thread_policy<mt_policy, A1, A2, A3, A4, A5, A6, A7, A8>; 660 using signal8 = signal_with_thread_policy<mt_policy, A1, A2, A3, A4, A5, A6, A7, A8>;
657 661
658 } // namespace sigslot 662 } // namespace sigslot
659 663
660 #endif // WEBRTC_BASE_SIGSLOT_H__ 664 #endif // WEBRTC_BASE_SIGSLOT_H__
OLDNEW
« no previous file with comments | « no previous file | webrtc/base/sigslot_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698