-
Notifications
You must be signed in to change notification settings - Fork 550
Expand file tree
/
Copy pathevents.cpp
More file actions
74 lines (59 loc) · 1.47 KB
/
events.cpp
File metadata and controls
74 lines (59 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*******************************************************
* Copyright (c) 2014, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#include <events.hpp>
#include <Event.hpp>
#include <common/err_common.hpp>
#include <af/device.h>
#include <af/event.h>
using detail::block;
using detail::createEvent;
using detail::enqueueWaitOnActiveQueue;
using detail::Event;
using detail::markEventOnActiveQueue;
Event &getEvent(af_event handle) {
Event &event = *static_cast<Event *>(handle);
return event;
}
af_event getHandle(Event &event) { return static_cast<af_event>(&event); }
af_err af_create_event(af_event *handle) {
try {
AF_CHECK(af_init());
*handle = createEvent();
}
CATCHALL;
return AF_SUCCESS;
}
af_err af_delete_event(af_event handle) {
try {
delete &getEvent(handle);
}
CATCHALL;
return AF_SUCCESS;
}
af_err af_mark_event(const af_event handle) {
try {
markEventOnActiveQueue(handle);
}
CATCHALL;
return AF_SUCCESS;
}
af_err af_enqueue_wait_event(const af_event handle) {
try {
enqueueWaitOnActiveQueue(handle);
}
CATCHALL;
return AF_SUCCESS;
}
af_err af_block_event(const af_event handle) {
try {
block(handle);
}
CATCHALL;
return AF_SUCCESS;
}