Skip to content

Commit 2c46108

Browse files
final missing piece
1 parent 87eeacb commit 2c46108

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

include/nbl/system/IAsyncQueueDispatcher.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class IAsyncQueueDispatcherBase
4242
void finalize(future_base_t* fut);
4343

4444
//! WORKER THREAD: returns when work is ready, will deadlock if the state will not eventually transition to pending
45-
[[nodiscard]] bool wait();
45+
[[nodiscard]] future_base_t* wait();
4646
//! WORKER THREAD: to call after request is done being processed, will deadlock if the request was not executed
4747
void notify();
4848

@@ -365,14 +365,14 @@ inline void IAsyncQueueDispatcherBase::request_base_t::finalize(future_base_t* f
365365
state.exchangeNotify<false>(STATE::PENDING,STATE::RECORDING);
366366
}
367367

368-
inline bool IAsyncQueueDispatcherBase::request_base_t::wait()
368+
inline IAsyncQueueDispatcherBase::future_base_t* IAsyncQueueDispatcherBase::request_base_t::wait()
369369
{
370370
if (state.waitAbortableTransition(STATE::EXECUTING,STATE::PENDING,STATE::CANCELLED) && future->disassociate_request())
371-
return true;
371+
return future;
372372
//assert(future->cancellable);
373373
future = nullptr;
374374
state.exchangeNotify<false>(STATE::INITIAL,STATE::CANCELLED);
375-
return false;
375+
return nullptr;
376376
}
377377
inline void IAsyncQueueDispatcherBase::request_base_t::notify()
378378
{
@@ -496,10 +496,10 @@ class IAsyncQueueDispatcher : public IThreadHandler<CRTP,InternalStateType>, pro
496496

497497
request_t& req = request_pool[r_id];
498498
// do NOT allow cancelling or modification of the request while working on it
499-
if (req.wait())
499+
if (future_base_t* future=req.wait())
500500
{
501501
// if the request supports cancelling and got cancelled, then `wait()` function may return false
502-
static_cast<CRTP*>(this)->process_request(nullptr/*TODO*/,req.m_metadata,optional_internal_state...);
502+
static_cast<CRTP*>(this)->process_request(future,req.m_metadata,optional_internal_state...);
503503
req.notify();
504504
}
505505
// wake the waiter up

include/nbl/system/ISystem.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,9 @@ class NBL_API2 ISystem : public core::IReferenceCounted
277277

278278
void init() {}
279279
};
280-
friend class ISystemFile; // TODO: do we need this friendship?
280+
// friendship needed to be able to know about the request types
281+
friend class ISystemFile;
282+
281283
CAsyncQueue m_dispatcher;
282284
};
283285

0 commit comments

Comments
 (0)