Skip to content

Commit abafa7a

Browse files
committed
~queue destructor is supposed to call asynchronous exception handler. Presently we do this in ~queue_impl, which isn't exactly compliant with spec, because it's possible that queue_impl may outlive queue because of shared pointer.
Signed-off-by: Chris Perkins <[email protected]>
1 parent bfc783f commit abafa7a

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

sycl/include/sycl/queue.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ class __SYCL_EXPORT queue : public detail::OwnerLessBase<queue> {
359359

360360
queue(queue &&RHS) = default;
361361

362+
~queue();
363+
362364
queue &operator=(const queue &RHS) = default;
363365

364366
queue &operator=(queue &&RHS) = default;

sycl/source/detail/queue_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class queue_impl : public std::enable_shared_from_this<queue_impl> {
255255
// notification and destroy the trace event for this queue.
256256
destructorNotification();
257257
#endif
258-
throw_asynchronous();
258+
259259
auto status =
260260
getAdapter().call_nocheck<UrApiKind::urQueueRelease>(MQueue);
261261
// If loader is already closed, it'll return a not-initialized status

sycl/source/queue.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ queue::queue(cl_command_queue clQueue, const context &SyclContext,
105105
*detail::getSyclObjImpl(SyclContext), AsyncHandler, PropList);
106106
}
107107

108+
queue::~queue() {
109+
impl->throw_asynchronous(); // <-- this should be safe in a noexcept context.
110+
}
111+
108112
cl_command_queue queue::get() const { return impl->get(); }
109113

110114
context queue::get_context() const { return impl->get_context(); }

0 commit comments

Comments
 (0)