2 // Copyright (c) 2016 Intel Corporation
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 ///////////////////////////////////////////////////////////////////////////////////////////////////
20 #include "refcounted_obj.h"
29 struct event_impl : public refcounted_obj<event_impl>
32 event_impl() = default;
36 virtual bool is_valid() const { return _attached; }
37 virtual void reset() { _attached = false; }
38 //returns true if handler has been successfully added
39 bool add_event_handler(cldnn_event_handler handler, void* data);
41 const std::list<cldnn_profiling_interval>& get_profiling_info();
44 std::mutex _handlers_mutex;
45 std::list<std::pair<cldnn_event_handler, void*>> _handlers;
47 bool _profiling_captured = false;
48 std::list<cldnn_profiling_interval> _profiling_info;
52 bool _attached = false; //because ocl event can be attached later, we need mechanism to check if such event was attached
55 virtual void wait_impl() = 0;
56 virtual bool is_set_impl() = 0;
57 virtual bool add_event_handler_impl(cldnn_event_handler, void*) { return true; }
59 //returns whether profiling info has been captures successfully and there's no need to call this impl a second time when user requests to get profling info
60 virtual bool get_profiling_info_impl(std::list<cldnn_profiling_interval>&) { return true; };
63 struct user_event : virtual public event_impl
66 user_event(bool set = false)
81 virtual void set_impl() = 0;
86 API_CAST(::cldnn_event, cldnn::event_impl)