MLX
Loading...
Searching...
No Matches
mlx
event.h
Go to the documentation of this file.
1
// Copyright © 2024 Apple Inc.
2
#pragma once
3
4
#include <memory>
5
#include <stdexcept>
6
7
#include "
mlx/stream.h
"
8
9
namespace
mlx::core
{
10
11
class
Event
{
12
public
:
13
Event
() {};
14
15
Event
(
const
Stream
& steam);
16
17
// Wait for the event to be signaled at its curent value
18
void
wait
();
19
20
// Signal the event at its current value
21
void
signal
();
22
23
// Check if the event is valid
24
bool
valid
() {
25
return
event_ !=
nullptr
;
26
};
27
28
uint64_t
value
() {
29
return
value_;
30
};
31
32
void
set_value
(uint64_t v) {
33
value_ = v;
34
};
35
36
const
Stream
&
stream
() {
37
if
(!
valid
()) {
38
throw
std::runtime_error(
39
"[Event::stream] Cannot access stream on invalid event."
);
40
}
41
return
stream_;
42
};
43
44
const
std::shared_ptr<void>&
raw_event
() {
45
return
event_;
46
};
47
48
private
:
49
// Default constructed stream should never be used
50
// since the event is not yet valid
51
Stream
stream_{0,
Device::cpu
};
52
std::shared_ptr<void> event_{
nullptr
};
53
uint64_t value_{0};
54
};
55
56
}
// namespace mlx::core
mlx::core::Event
Definition
event.h:11
mlx::core::Event::set_value
void set_value(uint64_t v)
Definition
event.h:32
mlx::core::Event::Event
Event(const Stream &steam)
mlx::core::Event::stream
const Stream & stream()
Definition
event.h:36
mlx::core::Event::valid
bool valid()
Definition
event.h:24
mlx::core::Event::wait
void wait()
mlx::core::Event::signal
void signal()
mlx::core::Event::raw_event
const std::shared_ptr< void > & raw_event()
Definition
event.h:44
mlx::core::Event::Event
Event()
Definition
event.h:13
mlx::core::Event::value
uint64_t value()
Definition
event.h:28
mlx::core
Definition
allocator.h:7
stream.h
mlx::core::Device::cpu
static constexpr DeviceType cpu
Definition
device.h:13
mlx::core::Stream
Definition
stream.h:9
Generated by
1.10.0