18 #ifndef LIBCWD_MACRO_FORALLDEBUGCHANNELS_H
19 #define LIBCWD_MACRO_FORALLDEBUGCHANNELS_H
21 #ifndef LIBCWD_CONFIG_H
24 #ifndef LIBCWD_PRIVATE_ASSERT_H
27 #ifndef LIBCWD_PRIVATE_INTERNAL_VECTOR_H
41 class debug_channels_ct {
43 typedef internal_vector<channel_ct*> container_type;
44 container_type* WNS_debug_channels;
46 void init(LIBCWD_TSD_PARAM);
47 #if LIBCWD_THREAD_SAFE
48 void init_and_rdlock();
50 container_type& write_locked();
51 container_type
const& read_locked()
const;
55 debug_channels_ct::container_type&
56 debug_channels_ct::write_locked()
59 LIBCWD_ASSERT( WNS_debug_channels );
61 return *WNS_debug_channels;
65 debug_channels_ct::container_type
const&
66 debug_channels_ct::read_locked()
const
69 LIBCWD_ASSERT( WNS_debug_channels );
71 return *WNS_debug_channels;
74 extern debug_channels_ct debug_channels;
79 #if LIBCWD_THREAD_SAFE
81 #define LIBCWD_ForAllDebugChannels_LOCK_TSD_DECLARATION LIBCWD_TSD_DECLARATION
83 #define LIBCWD_ForAllDebugChannels_LOCK_TSD_DECLARATION
85 #define LIBCWD_ForAllDebugChannels_LOCK \
86 LIBCWD_ForAllDebugChannels_LOCK_TSD_DECLARATION; \
87 LIBCWD_DEFER_CLEANUP_PUSH(&::libcwd::_private_::rwlock_tct< ::libcwd::_private_::debug_channels_instance>::cleanup, NULL); \
88 ::libcwd::_private_::debug_channels.init_and_rdlock()
89 #define LIBCWD_ForAllDebugChannels_UNLOCK \
90 ::libcwd::_private_::rwlock_tct< ::libcwd::_private_::debug_channels_instance>::rdunlock(); \
91 LIBCWD_CLEANUP_POP_RESTORE(false);
93 #define LIBCWD_ForAllDebugChannels_LOCK ::libcwd::_private_::debug_channels.init(LIBCWD_TSD)
94 #define LIBCWD_ForAllDebugChannels_UNLOCK
97 #define LibcwdForAllDebugChannels(dc_namespace, STATEMENT...) \
99 LIBCWD_ForAllDebugChannels_LOCK; \
100 for( ::libcwd::_private_::debug_channels_ct::container_type::\
101 const_iterator __libcwd_i(::libcwd::_private_::debug_channels.read_locked().begin());\
102 __libcwd_i != ::libcwd::_private_::debug_channels.read_locked().end(); ++__libcwd_i) \
104 using namespace ::libcwd; \
105 using namespace dc_namespace; \
106 ::libcwd::channel_ct& debugChannel(*(*__libcwd_i)); \
109 LIBCWD_ForAllDebugChannels_UNLOCK \
namespace for libcwd.
Definition: debug.cc:87