8#ifndef INCLUDED_BDLMT_SIGNALER
9#define INCLUDED_BDLMT_SIGNALER
233#include <bdlscm_version.h>
261#include <bsl_cstddef.h>
262#include <bsl_functional.h>
263#include <bsl_memory.h>
264#include <bsl_utility.h>
276class SignalerConnection;
300template <
class t_PROT>
317 TypeOrDefault ArgType;
344template <
class t_SIGNALER,
class t_PROT>
348template <
class t_SIGNALER>
356 void operator()()
const;
359template <
class t_SIGNALER,
class t_ARG1>
367 void operator()(t_ARG1)
const;
370template <
class t_SIGNALER,
class t_ARG1,
class t_ARG2>
378 void operator()(t_ARG1, t_ARG2)
const;
381template <
class t_SIGNALER,
class t_ARG1,
class t_ARG2,
class t_ARG3>
389 void operator()(t_ARG1, t_ARG2, t_ARG3)
const;
392template <
class t_SIGNALER,
404 void operator()(t_ARG1, t_ARG2, t_ARG3, t_ARG4)
const;
407template <
class t_SIGNALER,
414 void(t_ARG1, t_ARG2, t_ARG3, t_ARG4, t_ARG5)> {
421 void operator()(t_ARG1, t_ARG2, t_ARG3, t_ARG4, t_ARG5)
const;
424template <
class t_SIGNALER,
433 void(t_ARG1, t_ARG2, t_ARG3, t_ARG4, t_ARG5, t_ARG6)> {
440 void operator()(t_ARG1, t_ARG2, t_ARG3, t_ARG4, t_ARG5, t_ARG6)
const;
443template <
class t_SIGNALER,
453 void(t_ARG1, t_ARG2, t_ARG3, t_ARG4, t_ARG5, t_ARG6, t_ARG7)> {
460 void operator()(t_ARG1,
469template <
class t_SIGNALER,
480 void(t_ARG1, t_ARG2, t_ARG3, t_ARG4, t_ARG5, t_ARG6, t_ARG7, t_ARG8)> {
487 void operator()(t_ARG1,
497template <
class t_SIGNALER,
523 void operator()(t_ARG1,
588template <class t_PROT>
646 ForwardingNotArg)
const;
656 ForwardingNotArg)
const;
666 ForwardingNotArg)
const;
676 ForwardingNotArg)
const;
686 ForwardingNotArg)
const;
696 ForwardingNotArg)
const;
706 ForwardingNotArg)
const;
716 ForwardingNotArg)
const;
726 ForwardingNotArg)
const;
745 template <
class t_FUNC>
787 void invoke(typename
ArgumentType::ForwardingType1 arg1,
813template <class t_PROT>
872 template <
class t_FUNC>
960 bsl::size_t slotCount()
const;
974template <
class t_PROT>
1031 template <
class t_FUNC>
1118 bsl::
size_t slotCount() const;
1237 bool isConnected() const;
1258 bool d_waitOnDisconnect;
1292 bool waitOnDisconnect =
false);
1406template <class t_SIGNALER>
1410 static_cast<const t_SIGNALER *
>(
this)->d_signalerNodePtr->invoke(
1422template <
class t_SIGNALER,
class t_ARG1>
1427 static_cast<const t_SIGNALER *
>(
this)->d_signalerNodePtr->invoke(
1439template <
class t_SIGNALER,
class t_ARG1,
class t_ARG2>
1445 static_cast<const t_SIGNALER *
>(
this)->d_signalerNodePtr->invoke(
1457template <
class t_SIGNALER,
class t_ARG1,
class t_ARG2,
class t_ARG3>
1464 static_cast<const t_SIGNALER *
>(
this)->d_signalerNodePtr->invoke(
1476template <
class t_SIGNALER,
class t_ARG1,
1484 t_ARG4)>::operator()(
1490 static_cast<const t_SIGNALER *
>(
this)->d_signalerNodePtr->invoke(
1502template <
class t_SIGNALER,
class t_ARG1,
1513 operator()(t_ARG1 arg1,
1519 static_cast<const t_SIGNALER *
>(
this)->d_signalerNodePtr->invoke(
1531template <
class t_SIGNALER,
class t_ARG1,
1544 operator()(t_ARG1 arg1,
1551 static_cast<const t_SIGNALER *
>(
this)->d_signalerNodePtr->invoke(
1563template <
class t_SIGNALER,
class t_ARG1,
1578 t_ARG7)>::operator()(t_ARG1 arg1,
1586 static_cast<const t_SIGNALER *
>(
this)->d_signalerNodePtr->invoke(
1598template <
class t_SIGNALER,
class t_ARG1,
1615 t_ARG8)>::operator()(t_ARG1 arg1,
1624 static_cast<const t_SIGNALER *
>(
this)->d_signalerNodePtr->invoke(
1636template <
class t_SIGNALER,
class t_ARG1,
1656 t_ARG9)>::operator()(t_ARG1 arg1,
1666 static_cast<const t_SIGNALER *
>(
this)->d_signalerNodePtr->invoke(
1683template <
class t_PROT>
1694 ForwardingNotArg)
const
1699template <
class t_PROT>
1701void Signaler_SlotNode<t_PROT>::doInvoke(
1703 typename ArgumentType::ForwardingType1 arg1,
1711 ForwardingNotArg)
const
1718template <
class t_PROT>
1720void Signaler_SlotNode<t_PROT>::doInvoke(
1722 typename ArgumentType::ForwardingType1 arg1,
1723 typename ArgumentType::ForwardingType2 arg2,
1730 ForwardingNotArg)
const
1737template <
class t_PROT>
1739void Signaler_SlotNode<t_PROT>::doInvoke(
1741 typename ArgumentType::ForwardingType1 arg1,
1742 typename ArgumentType::ForwardingType2 arg2,
1743 typename ArgumentType::ForwardingType3 arg3,
1749 ForwardingNotArg)
const
1753 d_func(arg1, arg2, arg3);
1756template <
class t_PROT>
1758void Signaler_SlotNode<t_PROT>::doInvoke(
1760 typename ArgumentType::ForwardingType1 arg1,
1761 typename ArgumentType::ForwardingType2 arg2,
1762 typename ArgumentType::ForwardingType3 arg3,
1763 typename ArgumentType::ForwardingType4 arg4,
1768 ForwardingNotArg)
const
1772 d_func(arg1, arg2, arg3, arg4);
1775template <
class t_PROT>
1777void Signaler_SlotNode<t_PROT>::doInvoke(
1779 typename ArgumentType::ForwardingType1 arg1,
1780 typename ArgumentType::ForwardingType2 arg2,
1781 typename ArgumentType::ForwardingType3 arg3,
1782 typename ArgumentType::ForwardingType4 arg4,
1783 typename ArgumentType::ForwardingType5 arg5,
1787 ForwardingNotArg)
const
1791 d_func(arg1, arg2, arg3, arg4, arg5);
1794template <
class t_PROT>
1796void Signaler_SlotNode<t_PROT>::doInvoke(
1798 typename ArgumentType::ForwardingType1 arg1,
1799 typename ArgumentType::ForwardingType2 arg2,
1800 typename ArgumentType::ForwardingType3 arg3,
1801 typename ArgumentType::ForwardingType4 arg4,
1802 typename ArgumentType::ForwardingType5 arg5,
1803 typename ArgumentType::ForwardingType6 arg6,
1806 ForwardingNotArg)
const
1810 d_func(arg1, arg2, arg3, arg4, arg5, arg6);
1813template <
class t_PROT>
1815void Signaler_SlotNode<t_PROT>::doInvoke(
1817 typename ArgumentType::ForwardingType1 arg1,
1818 typename ArgumentType::ForwardingType2 arg2,
1819 typename ArgumentType::ForwardingType3 arg3,
1820 typename ArgumentType::ForwardingType4 arg4,
1821 typename ArgumentType::ForwardingType5 arg5,
1822 typename ArgumentType::ForwardingType6 arg6,
1823 typename ArgumentType::ForwardingType7 arg7,
1825 ForwardingNotArg)
const
1829 d_func(arg1, arg2, arg3, arg4, arg5, arg6, arg7);
1832template <
class t_PROT>
1834void Signaler_SlotNode<t_PROT>::doInvoke(
1836 typename ArgumentType::ForwardingType1 arg1,
1837 typename ArgumentType::ForwardingType2 arg2,
1838 typename ArgumentType::ForwardingType3 arg3,
1839 typename ArgumentType::ForwardingType4 arg4,
1840 typename ArgumentType::ForwardingType5 arg5,
1841 typename ArgumentType::ForwardingType6 arg6,
1842 typename ArgumentType::ForwardingType7 arg7,
1843 typename ArgumentType::ForwardingType8 arg8,
1844 ForwardingNotArg)
const
1848 d_func(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
1851template <
class t_PROT>
1853void Signaler_SlotNode<t_PROT>::doInvoke(
1855 typename ArgumentType::ForwardingType1 arg1,
1856 typename ArgumentType::ForwardingType2 arg2,
1857 typename ArgumentType::ForwardingType3 arg3,
1858 typename ArgumentType::ForwardingType4 arg4,
1859 typename ArgumentType::ForwardingType5 arg5,
1860 typename ArgumentType::ForwardingType6 arg6,
1861 typename ArgumentType::ForwardingType7 arg7,
1862 typename ArgumentType::ForwardingType8 arg8,
1863 typename ArgumentType::ForwardingType9 arg9)
const
1867 d_func(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
1871template <
class t_PROT>
1872template <
class t_FUNC>
1878: d_slotMapKey(slotMapKey)
1879, d_isConnected(true)
1880, d_signalerNodePtr(signalerNodePtr)
1881, d_func(
bsl::allocator_arg,
1890template <
class t_PROT>
1901 if (signalerNodePtr) {
1902 signalerNodePtr->notifyDisconnected(d_slotMapKey);
1906template <
class t_PROT>
1910 const bool wasConnected = d_isConnected.
testAndSwap(
true,
false);
1915 if (signalerNodePtr) {
1917 signalerNodePtr->notifyDisconnected(d_slotMapKey);
1922 signalerNodePtr->synchronizeWait();
1926template <
class t_PROT>
1930 d_isConnected =
false;
1934template <
class t_PROT>
1952 if (!d_isConnected) {
1961 arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
1964template <
class t_PROT>
1968 return d_isConnected;
1976template <
class t_PROT>
1979, d_slotMap(allocator)
1986template <
class t_PROT>
2011 if (d_slotMap.front(&slotHandle) != 0) {
2024 arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9);
2026 if (0 != d_slotMap.skipForward(&slotHandle)) {
2032 if (0 != d_slotMap.findUpperBound(&slotHandle, slotMapKey)) {
2038 }
while (slotHandle);
2041template <
class t_PROT>
2042template <
class t_FUNC>
2049 const SlotMapKey slotMapKey(group, ++d_keyId);
2054 d_slotMap.allocator(),
2055 this->weak_from_this(),
2058 d_slotMap.allocator());
2062 d_slotMap.addR(slotMapKey, slotNodePtr);
2070template <
class t_PROT>
2077 while (d_slotMap.front(&slotHandle) == 0) {
2080 slotHandle.
data()->notifyDisconnected();
2084 d_slotMap.remove(slotHandle);
2088template <
class t_PROT>
2091 disconnectAllSlots();
2095template <
class t_PROT>
2104 while (0 == d_slotMap.findLowerBound(&slotHandle, boundary) &&
2105 slotHandle.
key().first == group) {
2109 slotHandle.
data()->notifyDisconnected();
2113 if (0 != d_slotMap.skipForward(&slotHandle)) {
2119 d_slotMap.remove(condemned);
2120 }
while (slotHandle && slotHandle.
key().first == group);
2124template <
class t_PROT>
2128 disconnectGroup(group);
2132template <
class t_PROT>
2138 if (d_slotMap.find(&slotHandle, slotMapKey) != 0) {
2147 d_slotMap.remove(slotHandle);
2150template <
class t_PROT>
2158template <
class t_PROT>
2162 return d_slotMap.length();
2170template <
class t_PROT>
2174 bslma::Default::allocator(basicAllocator)))
2179template <
class t_PROT>
2183 d_signalerNodePtr->disconnectAllSlots();
2187template <
class t_PROT>
2188template <
class t_FUNC>
2199template <
class t_PROT>
2203 d_signalerNodePtr->disconnectAllSlots();
2206template <
class t_PROT>
2210 d_signalerNodePtr->disconnectAllSlotsAndWait();
2213template <
class t_PROT>
2217 d_signalerNodePtr->disconnectGroup(group);
2220template <
class t_PROT>
2224 d_signalerNodePtr->disconnectGroupAndWait(group);
2228template <
class t_PROT>
2232 return d_signalerNodePtr->slotCount();
2243 d_slotNodeBasePtr.
swap(other.d_slotNodeBasePtr);
2250 return lhs.d_slotNodeBasePtr.rep() == rhs.d_slotNodeBasePtr.rep();
2256 return lhs.d_slotNodeBasePtr.owner_before(rhs.d_slotNodeBasePtr);
2276 return d_connection;
2282 return d_waitOnDisconnect;
#define BSLMF_NESTED_TRAIT_DECLARATION(t_TYPE, t_TRAIT)
Definition bslmf_nestedtraitdeclaration.h:231
Definition bdlcc_skiplist.h:693
void release()
Release the reference (if any) managed by this SkipListPairHandle.
Definition bdlcc_skiplist.h:1852
DATA & data() const
Definition bdlcc_skiplist.h:1889
const KEY & key() const
Definition bdlcc_skiplist.h:1905
Definition bdlcc_skiplist.h:783
Definition bdlmt_signaler.h:1253
bool waitOnDisconnect() const BSLS_KEYWORD_NOEXCEPT
Definition bdlmt_signaler.h:2280
const SignalerConnection & connection() const BSLS_KEYWORD_NOEXCEPT
Definition bdlmt_signaler.h:2273
SignalerConnectionGuard(bslmf::MovableRef< SignalerConnection > connection, bool waitOnDisconnect=false) BSLS_KEYWORD_NOEXCEPT
SignalerConnectionGuard(const SignalerConnection &connection, bool waitOnDisconnect=false)
SignalerConnectionGuard()
BSLMF_NESTED_TRAIT_DECLARATION(SignalerConnectionGuard, bslmf::IsBitwiseMoveable)
Definition bdlmt_signaler.h:1133
SignalerConnection(bslmf::MovableRef< SignalerConnection > original) BSLS_KEYWORD_NOEXCEPT
SignalerConnection & operator=(bslmf::MovableRef< SignalerConnection > rhs) BSLS_KEYWORD_NOEXCEPT
SignalerConnection()
Create a SignalerConnection object having no associated slot.
void reset() BSLS_KEYWORD_NOEXCEPT
SignalerConnection & operator=(const SignalerConnection &rhs)
SignalerConnection(const SignalerConnection &original) BSLS_KEYWORD_NOEXCEPT
void swap(SignalerConnection &other) BSLS_KEYWORD_NOEXCEPT
Definition bdlmt_signaler.h:2241
Definition bdlmt_signaler.h:815
SignalerConnection connect(BSLS_COMPILERFEATURES_FORWARD_REF(t_FUNC) slot, int group)
Definition bdlmt_signaler.h:2043
void synchronizeWait() BSLS_KEYWORD_NOEXCEPT
Definition bdlmt_signaler.h:2152
void disconnectGroup(int group) BSLS_KEYWORD_NOEXCEPT
Definition bdlmt_signaler.h:2096
void disconnectAllSlots() BSLS_KEYWORD_NOEXCEPT
Definition bdlmt_signaler.h:2071
void notifyDisconnected(SlotMapKey slotMapKey) BSLS_KEYWORD_NOEXCEPT
Definition bdlmt_signaler.h:2133
void disconnectGroupAndWait(int group) BSLS_KEYWORD_NOEXCEPT
Definition bdlmt_signaler.h:2125
void invoke(typename ArgumentType::ForwardingType1 arg1, typename ArgumentType::ForwardingType2 arg2, typename ArgumentType::ForwardingType3 arg3, typename ArgumentType::ForwardingType4 arg4, typename ArgumentType::ForwardingType5 arg5, typename ArgumentType::ForwardingType6 arg6, typename ArgumentType::ForwardingType7 arg7, typename ArgumentType::ForwardingType8 arg8, typename ArgumentType::ForwardingType9 arg9) const
Definition bdlmt_signaler.h:1988
void disconnectAllSlotsAndWait() BSLS_KEYWORD_NOEXCEPT
Definition bdlmt_signaler.h:2089
bsl::size_t slotCount() const
Definition bdlmt_signaler.h:2160
Definition bdlmt_signaler.h:543
virtual ~Signaler_SlotNode_Base()
Virtual d'tor.
virtual bool isConnected() const =0
virtual void disconnectAndWait() BSLS_KEYWORD_NOEXCEPT=0
virtual void disconnect() BSLS_KEYWORD_NOEXCEPT=0
Definition bdlmt_signaler.h:589
void disconnectAndWait() BSLS_KEYWORD_NOEXCEPT BSLS_KEYWORD_OVERRIDE
Definition bdlmt_signaler.h:1908
bsl::pair< int, unsigned > SlotMapKey
Definition bdlmt_signaler.h:603
void notifyDisconnected() BSLS_KEYWORD_NOEXCEPT
Definition bdlmt_signaler.h:1928
void invoke(typename ArgumentType::ForwardingType1 arg1, typename ArgumentType::ForwardingType2 arg2, typename ArgumentType::ForwardingType3 arg3, typename ArgumentType::ForwardingType4 arg4, typename ArgumentType::ForwardingType5 arg5, typename ArgumentType::ForwardingType6 arg6, typename ArgumentType::ForwardingType7 arg7, typename ArgumentType::ForwardingType8 arg8, typename ArgumentType::ForwardingType9 arg9) const
Definition bdlmt_signaler.h:1936
void disconnect() BSLS_KEYWORD_NOEXCEPT BSLS_KEYWORD_OVERRIDE
Definition bdlmt_signaler.h:1892
bool isConnected() const BSLS_KEYWORD_OVERRIDE
Definition bdlmt_signaler.h:1966
~Signaler_SlotNode()=default
Destroy this object.
Definition bdlmt_signaler.h:975
SignalerConnection connect(BSLS_COMPILERFEATURES_FORWARD_REF(t_FUNC) slot, int group=0)
Definition bdlmt_signaler.h:2190
void disconnectGroupAndWait(int group) BSLS_KEYWORD_NOEXCEPT
Definition bdlmt_signaler.h:2222
void disconnectGroup(int group) BSLS_KEYWORD_NOEXCEPT
Definition bdlmt_signaler.h:2215
void disconnectAllSlots() BSLS_KEYWORD_NOEXCEPT
Definition bdlmt_signaler.h:2201
void disconnectAllSlotsAndWait() BSLS_KEYWORD_NOEXCEPT
Definition bdlmt_signaler.h:2208
void ResultType
Definition bdlmt_signaler.h:979
~Signaler()
Definition bdlmt_signaler.h:2181
bsl::size_t slotCount() const
Definition bdlmt_signaler.h:2230
Forward declaration.
Definition bslstl_function.h:934
Definition bslstl_pair.h:1210
Definition bslstl_sharedptr.h:1830
Definition bslstl_sharedptr.h:3705
void swap(weak_ptr &other) BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:5913
bool expired() const BSLS_KEYWORD_NOEXCEPT
Definition bslstl_sharedptr.h:5934
Definition bslma_allocator.h:457
Provide a namespace for the forwardToTarget function.
Definition bslmf_forwardingtype.h:454
Imp::Type Type
Definition bslmf_forwardingtype.h:439
Definition bslmf_movableref.h:751
Definition bslmt_readlockguard.h:287
Definition bslmt_readerwritermutex.h:244
Definition bslmt_writelockguard.h:221
Definition bsls_atomic.h:1472
bool testAndSwap(bool compareValue, bool swapValue)
Definition bsls_atomic.h:2479
Definition bsls_atomic.h:1043
#define BSLS_ASSERT(X)
Definition bsls_assert.h:1804
#define BSLS_COMPILERFEATURES_FORWARD_REF(T)
Definition bsls_compilerfeatures.h:2012
#define BSLS_COMPILERFEATURES_FORWARD(T, V)
Definition bsls_compilerfeatures.h:2018
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_KEYWORD_DELETED
Definition bsls_keyword.h:609
#define BSLS_KEYWORD_NOEXCEPT
Definition bsls_keyword.h:632
#define BSLS_KEYWORD_OVERRIDE
Definition bsls_keyword.h:653
Definition bdlmt_eventscheduler.h:522
Definition bdlb_printmethods.h:283
Definition balxml_encoderoptions.h:68
Definition bdlbb_blob.h:576
Definition bdlmt_signaler.h:301
Forward< 5 >::Type ForwardingType5
Definition bdlmt_signaler.h:331
Forward< 6 >::Type ForwardingType6
Definition bdlmt_signaler.h:332
Forward< 4 >::Type ForwardingType4
Definition bdlmt_signaler.h:330
Forward< 9 >::Type ForwardingType9
Definition bdlmt_signaler.h:335
Forward< 3 >::Type ForwardingType3
Definition bdlmt_signaler.h:329
bslmf::ForwardingType< Signaler_NotArg >::Type ForwardingNotArg
Definition bdlmt_signaler.h:325
Forward< 1 >::Type ForwardingType1
Definition bdlmt_signaler.h:327
Forward< 2 >::Type ForwardingType2
Definition bdlmt_signaler.h:328
Forward< 7 >::Type ForwardingType7
Definition bdlmt_signaler.h:333
Forward< 8 >::Type ForwardingType8
Definition bdlmt_signaler.h:334
Definition bdlmt_signaler.h:345
Provides a "Not an Argument" tag type.
Definition bdlmt_signaler.h:283
Definition bslmf_integralconstant.h:244
Definition bslma_usesbslmaallocator.h:343
Definition bslmf_functionpointertraits.h:137
Definition bslmf_isbitwisemoveable.h:718
Definition bslmf_typelist.h:1625