Skip to content

Commit 4ec95b0

Browse files
authored
[UR] Make ur::handle_base non-copyable (#18901)
All UR handles should be defined as non-copyable objects. By deleting the copy constructor and assignement operator in `ur::handle_base` we can do this in a centralized location. This should also resolve rule of three violations in adapter handle objects.
1 parent 5cb4647 commit 4ec95b0

File tree

1 file changed

+9
-1
lines changed
  • unified-runtime/source/ur

1 file changed

+9
-1
lines changed

unified-runtime/source/ur/ur.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,17 @@ extern bool PrintTrace;
380380
// The getInfo*/ReturnHelper facilities provide shortcut way of
381381
// writing return bytes for the various getInfo APIs.
382382
namespace ur {
383+
384+
// Base class for handles, stores the ddi table used by the loader to
385+
// dispatch to the correct adapter implementation of entry points.
383386
template <typename getddi> struct handle_base {
384-
handle_base() { ddi_table = getddi::value(); };
385387
const ur_dditable_t *ddi_table = nullptr;
388+
389+
handle_base() { ddi_table = getddi::value(); };
390+
391+
// Handles are non-copyable.
392+
handle_base(const handle_base &) = delete;
393+
handle_base &operator=(const handle_base &) = delete;
386394
};
387395

388396
template <typename T, typename Assign>

0 commit comments

Comments
 (0)