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

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

Issue 2854053002: Revert of 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& o) : _signal_base_interface(&_s ignal_base::do_slot_disconnect, &_signal_base::do_slot_duplicate) { 410 » » _signal_base(const _signal_base& s) : _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 for (const auto& connection : o.m_connected_slots) 412 » » » connections_list::const_iterator it = m_connected_slots. begin();
413 » » » connections_list::const_iterator itEnd = m_connected_slo ts.end();
414 » » » while(it != itEnd)
413 { 415 {
414 » » » » connection.getdest()->signal_connect(this); 416 » » » » it->getdest()->signal_connect(this);
415 » » » » m_connected_slots.push_back(connection); 417 » » » » m_connected_slots.push_back(*it);
418 » » » » ++it;
416 } 419 }
417 } 420 }
418 421
419 bool is_empty() 422 bool is_empty()
420 { 423 {
421 lock_block<mt_policy> lock(this); 424 lock_block<mt_policy> lock(this);
422 return m_connected_slots.empty(); 425 return m_connected_slots.empty();
423 } 426 }
424 427
425 void disconnect_all() 428 void disconnect_all()
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 { 521 {
519 private: 522 private:
520 typedef std::set< _signal_base_interface* > sender_set; 523 typedef std::set< _signal_base_interface* > sender_set;
521 typedef sender_set::const_iterator const_iterator; 524 typedef sender_set::const_iterator const_iterator;
522 525
523 public: 526 public:
524 has_slots() : has_slots_interface(&has_slots::do_signal_connect, &has_slots::do_signal_disconnect, &has_slots::do_disconnect_all) 527 has_slots() : has_slots_interface(&has_slots::do_signal_connect, &has_slots::do_signal_disconnect, &has_slots::do_disconnect_all)
525 { 528 {
526 } 529 }
527 530
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 {
530 lock_block<mt_policy> lock(this);
531 for (auto* sender : o.m_senders) {
532 sender->slot_duplicate(&o, this);
533 m_senders.insert(sender);
534 }
535 }
536
537 ~has_slots() 531 ~has_slots()
538 { 532 {
539 this->disconnect_all(); 533 this->disconnect_all();
540 } 534 }
541 535
542 private: 536 private:
537 has_slots(has_slots const&);
543 has_slots& operator= (has_slots const&); 538 has_slots& operator= (has_slots const&);
544 539
545 static void do_signal_connect(has_slots_interface* p, _signal_ba se_interface* sender) 540 static void do_signal_connect(has_slots_interface* p, _signal_ba se_interface* sender)
546 { 541 {
547 has_slots* const self = static_cast< has_slots* >(p); 542 has_slots* const self = static_cast< has_slots* >(p);
548 lock_block<mt_policy> lock(self); 543 lock_block<mt_policy> lock(self);
549 self->m_senders.insert(sender); 544 self->m_senders.insert(sender);
550 } 545 }
551 546
552 static void do_signal_disconnect(has_slots_interface* p, _signal _base_interface* sender) 547 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
656 651
657 template<typename A1, typename A2, typename A3, typename A4, typename A5 , typename A6, typename A7, typename mt_policy = SIGSLOT_DEFAULT_MT_POLICY> 652 template<typename A1, typename A2, typename A3, typename A4, typename A5 , typename A6, typename A7, typename mt_policy = SIGSLOT_DEFAULT_MT_POLICY>
658 using signal7 = signal_with_thread_policy<mt_policy, A1, A2, A3, A4, A5, A6, A7>; 653 using signal7 = signal_with_thread_policy<mt_policy, A1, A2, A3, A4, A5, A6, A7>;
659 654
660 template<typename A1, typename A2, typename A3, typename A4, typename A5 , typename A6, typename A7, typename A8, typename mt_policy = SIGSLOT_DEFAULT_MT _POLICY> 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>
661 using signal8 = signal_with_thread_policy<mt_policy, A1, A2, A3, A4, A5, A6, A7, A8>; 656 using signal8 = signal_with_thread_policy<mt_policy, A1, A2, A3, A4, A5, A6, A7, A8>;
662 657
663 } // namespace sigslot 658 } // namespace sigslot
664 659
665 #endif // WEBRTC_BASE_SIGSLOT_H__ 660 #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