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 ///////////////////////////////////////////////////////////////////////////////////////////////////
19 #include "api/event.hpp"
20 #include "refcounted_obj.h"
29 struct event_impl : public refcounted_obj<event_impl> {
31 event_impl() = default;
35 virtual bool is_valid() const { return _attached; }
36 virtual void reset() {
39 _profiling_captured = false;
40 _profiling_info.clear();
42 // returns true if handler has been successfully added
43 bool add_event_handler(event_handler handler, void* data);
45 const std::list<instrumentation::profiling_interval>& get_profiling_info();
48 std::mutex _handlers_mutex;
49 std::list<std::pair<event_handler, void*>> _handlers;
51 bool _profiling_captured = false;
52 std::list<instrumentation::profiling_interval> _profiling_info;
57 false; // because ocl event can be attached later, we need mechanism to check if such event was attached
60 virtual void wait_impl() = 0;
61 virtual bool is_set_impl() = 0;
62 virtual bool add_event_handler_impl(event_handler, void*) { return true; }
64 // returns whether profiling info has been captures successfully and there's no need to call this impl a second time
65 // when user requests to get profling info
66 virtual bool get_profiling_info_impl(std::list<instrumentation::profiling_interval>&) { return true; }
69 struct user_event : virtual public event_impl {
71 explicit user_event(bool set = false) { _set = set; }
82 virtual void set_impl() = 0;