@@ -35,7 +35,11 @@ using QueueImplPtr = std::shared_ptr<sycl::detail::queue_impl>;
3535class event_impl ;
3636using EventImplPtr = std::shared_ptr<sycl::detail::event_impl>;
3737
38- class event_impl {
38+ class event_impl : public std ::enable_shared_from_this<event_impl> {
39+ struct private_tag {
40+ explicit private_tag () = default;
41+ };
42+
3943public:
4044 enum HostEventState : int {
4145 HES_NotComplete = 0 ,
@@ -46,11 +50,9 @@ class event_impl {
4650 // / Constructs a ready SYCL event.
4751 // /
4852 // / If the constructed SYCL event is waited on it will complete immediately.
49- // / Normally constructs a host event, use std::nullopt to instead instantiate
50- // / a device event.
51- event_impl (std::optional<HostEventState> State = HES_Complete)
52- : MIsFlushed(true ), MState(State.value_or(HES_Complete)),
53- MIsDefaultConstructed (!State), MIsHostEvent(State) {
53+ event_impl (private_tag)
54+ : MIsFlushed(true ), MState(HES_Complete), MIsDefaultConstructed(true ),
55+ MIsHostEvent (false ) {
5456 // Need to fail in event() constructor if there are problems with the
5557 // ONEAPI_DEVICE_SELECTOR. Deferring may lead to conficts with noexcept
5658 // event methods. This ::get() call uses static vars to read and parse the
@@ -65,8 +67,39 @@ class event_impl {
6567 // /
6668 // / \param Event is a valid instance of UR event.
6769 // / \param SyclContext is an instance of SYCL context.
68- event_impl (ur_event_handle_t Event, const context &SyclContext);
69- event_impl (const QueueImplPtr &Queue);
70+ event_impl (ur_event_handle_t Event, const context &SyclContext, private_tag);
71+
72+ event_impl (queue_impl &Queue, private_tag);
73+ event_impl (HostEventState State, private_tag);
74+
75+ // Corresponds to `sycl::event{}`.
76+ static std::shared_ptr<event_impl> create_default_event () {
77+ return std::make_shared<event_impl>(private_tag{});
78+ }
79+
80+ static std::shared_ptr<event_impl>
81+ create_from_handle (ur_event_handle_t Event, const context &SyclContext) {
82+ return std::make_shared<event_impl>(Event, SyclContext, private_tag{});
83+ }
84+
85+ static std::shared_ptr<event_impl> create_device_event (queue_impl &queue) {
86+ return std::make_shared<event_impl>(queue, private_tag{});
87+ }
88+
89+ static std::shared_ptr<event_impl> create_discarded_event () {
90+ return std::make_shared<event_impl>(HostEventState::HES_Discarded,
91+ private_tag{});
92+ }
93+
94+ static std::shared_ptr<event_impl> create_completed_host_event () {
95+ return std::make_shared<event_impl>(HostEventState::HES_Complete,
96+ private_tag{});
97+ }
98+
99+ static std::shared_ptr<event_impl> create_incomplete_host_event () {
100+ return std::make_shared<event_impl>(HostEventState::HES_NotComplete,
101+ private_tag{});
102+ }
70103
71104 // / Sets a queue associated with the event
72105 // /
0 commit comments