Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PENGUINLIONG committed Dec 21, 2022
1 parent 876acb5 commit 1d7db13
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions c_api/include/taichi/cpp/taichi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,60 @@ class AotModule {
}
};

class Event {
TiRuntime runtime_{TI_NULL_HANDLE};
TiEvent event_{TI_NULL_HANDLE};
bool should_destroy_{false};

public:
constexpr bool is_valid() const {
return event_ != nullptr;
}
inline void destroy() {
if (should_destroy_) {
ti_destroy_event(event_);
event_ = TI_NULL_HANDLE;
should_destroy_ = false;
}
}

Event() {
}
Event(const Event &) = delete;
Event(Event &&b) : event_(b.event_), should_destroy_(b.should_destroy_) {
}
Event(TiRuntime runtime, TiEvent event, bool should_destroy)
: runtime_(runtime), event_(event), should_destroy_(should_destroy) {
}
~Event() {
destroy();
}

Event &operator=(const Event &) = delete;
Event &operator=(Event &&b) {
event_ = detail::move_handle(b.event_);
should_destroy_ = std::exchange(b.should_destroy_, false);
return *this;
}

void reset(TiEvent event_) {
ti_reset_event(runtime_, event_);
}
void signal(TiEvent event_) {
ti_signal_event(runtime_, event_);
}
void wait(TiEvent event_) {
ti_wait_event(runtime_, event_);
}

constexpr TiEvent event() const {
return event_;
}
constexpr operator TiEvent() const {
return event_;
}
};

class CapabilityLevelConfigBuilder;
class CapabilityLevelConfig {
public:
Expand Down

0 comments on commit 1d7db13

Please sign in to comment.