1 #include "hmbdc/Copyright.hpp" 4 #include "hmbdc/app/Client.hpp" 5 #include "hmbdc/app/Message.hpp" 6 #include "hmbdc/comm/Topic.hpp" 8 #include "hmbdc/pattern/PoolT.hpp" 9 #include "hmbdc/pattern/PoolMinus.hpp" 10 #include "hmbdc/pattern/LockFreeBufferT.hpp" 11 #include "hmbdc/pattern/MonoLockFreeBuffer.hpp" 13 #include "hmbdc/os/Thread.hpp" 14 #include "hmbdc/os/Allocators.hpp" 15 #include "hmbdc/time/Timers.hpp" 18 #include <type_traits> 22 namespace hmbdc {
namespace app {
namespace context_detail {
26 template <
typename CcClient>
29 template <
typename U = CcClient>
31 ,
typename std::enable_if<std::is_base_of<time::TimerManager, U>::value>::type* =
nullptr)
35 template <
typename U = CcClient>
37 ,
typename std::enable_if<!std::is_base_of<time::TimerManager, U>::value>::type* =
nullptr)
41 virtual void handleRangeImpl(
BufIt it,
42 BufIt end, uint16_t threadSerialNumber)
override {
43 client_.CcClient::handleRangeImpl(it, end, threadSerialNumber);
45 virtual void messageDispatchingStartedCb(uint16_t threadId)
override {
46 client_.CcClient::messageDispatchingStartedCb(threadId);
48 virtual void invokedCb(uint16_t threadId)
override {
49 client_.CcClient::invokedCb(threadId);
51 virtual void stoppedCb(std::exception
const&e)
override {
52 client_.CcClient::stoppedCb(e);
54 virtual bool droppedCb()
override {
55 if (client_.CcClient::droppedCb()) {
63 CcClient& HMBDC_RESTRICT client_;
66 template <
typename... ContextProperties>
81 template <uint16_t c,
typename... ContextProperties>
83 , ContextProperties...>
93 template <
typename... ContextProperties>
95 , ContextProperties...>
104 template <
typename... ContextProperties>
106 , ContextProperties...>
114 template <
typename... ContextProperties>
116 , ContextProperties...>
124 template <
typename... ContextProperties>
126 , ContextProperties...>
134 template <
typename... ContextProperties>
136 , ContextProperties...>
147 template <
bool is_timer_manager>
150 void operator()(C&) {}
156 tm.checkTimers(SysTime::now());
160 template <
typename LFB,
typename CcClient>
161 bool runOnceImpl(uint16_t hmbdcNumber,
bool& HMBDC_RESTRICT stopped
162 , LFB& HMBDC_RESTRICT lfb, CcClient& HMBDC_RESTRICT c) {
163 typename LFB::iterator begin, end;
168 using Cc =
typename std::decay<CcClient>::type;
170 const bool clientParticipateInMessaging = Cc::INTERESTS_SIZE != 0;
171 if (clientParticipateInMessaging) {
172 uint64_t count = lfb.peek(hmbdcNumber, begin, end, c.maxBatchMessageCount());
173 c.Cc::handleRangeImpl(begin, end, hmbdcNumber);
174 c.Cc::invokedCb(hmbdcNumber);
175 lfb.wasteAfterPeek(hmbdcNumber, count);
177 c.Cc::invokedCb(0xffffu - hmbdcNumber);
179 }
catch (std::exception
const& e) {
198 template <
typename CcClient>
199 bool runOnceImpl(uint16_t threadSerialNumber,
bool& HMBDC_RESTRICT stopped
206 using Cc =
typename std::decay<CcClient>::type;
207 const bool clientParticipateInMessaging = Cc::INTERESTS_SIZE != 0;
208 if (clientParticipateInMessaging) {
209 uint64_t count = lfb.peek(begin, end, c.maxBatchMessageCount());
210 c.Cc::handleRangeImpl(begin, end, threadSerialNumber);
211 c.Cc::invokedCb(threadSerialNumber);
212 lfb.wasteAfterPeek(begin, count);
214 c.Cc::invokedCb(0xffffu - threadSerialNumber);
216 }
catch (std::exception
const& e) {
240 template <
typename Buffer>
241 void unblock(Buffer& lfb, uint16_t threadSerialNumber) {
242 lfb.markDead(threadSerialNumber);
Definition: MonoLockFreeBuffer.hpp:15
Definition: ContextDetail.hpp:67
Definition: ContextDetail.hpp:148
Definition: TypedString.hpp:76
Definition: Timers.hpp:66
the default vanilla allocate
Definition: Allocators.hpp:145
Unknown excpetion.
Definition: Exception.hpp:17
similar to ShmBasePtrAllocator but using dev memory
Definition: Allocators.hpp:117
Definition: BlockingBuffer.hpp:10
Definition: ContextDetail.hpp:27
Definition: LockFreeBufferT.hpp:18
Definition: PoolConsumer.hpp:13
Exception that just has an exit code.
Definition: Exception.hpp:28
helping allocating object and its aggregated objects in a continouse shared memory ...
Definition: Allocators.hpp:88
Definition: LockFreeBufferMisc.hpp:89