@@ -58,6 +58,7 @@ class IAsyncQueueDispatcherBase
58
58
59
59
protected:
60
60
// the base class is not directly usable
61
+ inline request_base_t () = default;
61
62
inline ~request_base_t ()
62
63
{
63
64
// fully cleaned up
@@ -114,6 +115,7 @@ class IAsyncQueueDispatcherBase
114
115
}
115
116
116
117
// the base class is not directly usable
118
+ inline future_base_t () = default;
117
119
virtual inline ~future_base_t ()
118
120
{
119
121
// non-cancellable future just need to get to this state, and cancellable will move here
@@ -127,7 +129,7 @@ class IAsyncQueueDispatcherBase
127
129
128
130
// this tells us whether an object with a lifetime has been constructed over the memory backing the future
129
131
// also acts as a lock
130
- atomic_state_t <STATE,STATE::INITIAL> state= {};
132
+ atomic_state_t <STATE,STATE::INITIAL> state = {};
131
133
};
132
134
133
135
// not meant for direct usage
@@ -146,7 +148,7 @@ class IAsyncQueueDispatcherBase
146
148
}
147
149
148
150
public:
149
- inline future_t () {}
151
+ inline future_t () : future_base_t() {}
150
152
inline ~future_t ()
151
153
{
152
154
discard ();
@@ -258,6 +260,8 @@ class IAsyncQueueDispatcherBase
258
260
}
259
261
260
262
protected:
263
+ // to get access to the below
264
+ friend class IAsyncQueueDispatcherBase ;
261
265
// construct the retval element
262
266
template <typename ... Args>
263
267
inline void construct (Args&&... args)
@@ -331,6 +335,21 @@ class IAsyncQueueDispatcherBase
331
335
return false ;
332
336
}
333
337
};
338
+
339
+ protected:
340
+ template <typename T>
341
+ class future_constructor_t final
342
+ {
343
+ future_t <T>* pFuture;
344
+ public:
345
+ inline future_constructor_t (future_base_t * _future_base) : pFuture(static_cast <future_t <T>*>(_future_base)) {}
346
+
347
+ template <typename ... Args>
348
+ inline void operator ()(Args&&... args)
349
+ {
350
+ pFuture->construct (std::forward<Args>(args)...);
351
+ }
352
+ };
334
353
};
335
354
336
355
inline void IAsyncQueueDispatcherBase::request_base_t::finalize (future_base_t * fut)
@@ -388,7 +407,9 @@ class IAsyncQueueDispatcher : public IThreadHandler<CRTP,InternalStateType>, pro
388
407
389
408
struct request_t : public request_base_t
390
409
{
391
- request_metadata_t m_metadata;
410
+ inline request_t () : request_base_t() {}
411
+
412
+ request_metadata_t m_metadata = {};
392
413
};
393
414
394
415
private:
@@ -410,7 +431,7 @@ class IAsyncQueueDispatcher : public IThreadHandler<CRTP,InternalStateType>, pro
410
431
411
432
public:
412
433
inline IAsyncQueueDispatcher () {}
413
- inline IAsyncQueueDispatcher (base_t ::start_on_construction_t ) : base_t(base_t ::start_on_construction_t ) {}
434
+ inline IAsyncQueueDispatcher (base_t ::start_on_construction_t ) : base_t(base_t ::start_on_construction ) {}
414
435
415
436
using mutex_t = typename base_t ::mutex_t ;
416
437
using lock_t = typename base_t ::lock_t ;
@@ -454,7 +475,7 @@ class IAsyncQueueDispatcher : public IThreadHandler<CRTP,InternalStateType>, pro
454
475
inline void background_work () {}
455
476
456
477
private:
457
- template <typename ... Args>
478
+ template <typename ... Args>
458
479
void work (lock_t & lock, Args&&... optional_internal_state)
459
480
{
460
481
lock.unlock ();
@@ -472,7 +493,7 @@ class IAsyncQueueDispatcher : public IThreadHandler<CRTP,InternalStateType>, pro
472
493
if (req.wait ())
473
494
{
474
495
// if the request supports cancelling and got cancelled, then `wait()` function may return false
475
- static_cast <CRTP*>(this )->process_request (req.m_metadata ,optional_internal_state...);
496
+ static_cast <CRTP*>(this )->process_request (nullptr /* TODO */ , req.m_metadata ,optional_internal_state...);
476
497
req.notify ();
477
498
}
478
499
// wake the waiter up
0 commit comments