Skip to content

Commit b59752b

Browse files
committed
Code style + file renaming.
1 parent 4fc5b5a commit b59752b

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

src/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ set(
194194
periodic_concurrency_worker.h
195195
thread_config.h
196196
cuda_runtime_library_manager.h
197-
coroutines.h
197+
coroutine.h
198198
)
199199

200200
add_executable(

src/coroutines.h renamed to src/coroutine.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,13 @@ class Coroutine {
6868
friend struct Coroutine;
6969
};
7070

71-
Awaiter awaiter() { return Awaiter(this); }
71+
Awaiter CreateAwaiter() { return Awaiter(this); }
7272

73-
void resume()
73+
void Resume()
7474
{
75-
if (!handle_)
75+
if (!handle_) {
7676
return;
77+
}
7778
if (!suspended_) {
7879
earlyResume_ = true;
7980
return;
@@ -82,10 +83,11 @@ class Coroutine {
8283
handle_.resume();
8384
}
8485

85-
bool done()
86+
bool Done()
8687
{
87-
if (!handle_)
88+
if (!handle_) {
8889
return true;
90+
}
8991
bool isDone = handle_.done();
9092
if (isDone) {
9193
if constexpr (!std::is_void<T>::value) {
@@ -97,7 +99,7 @@ class Coroutine {
9799
return isDone;
98100
}
99101

100-
const SafeT& value() const { return value_; }
102+
const SafeT& Value() const { return value_; }
101103

102104
private:
103105
struct PromiseVoid {
@@ -160,7 +162,7 @@ class Coroutine {
160162
{
161163
auto& promise = handle_.promise();
162164
promise.awaitingCoroutine_ = h.address();
163-
resume();
165+
Resume();
164166
}
165167
constexpr SafeT await_resume()
166168
{

src/test_coroutines.cc

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2525
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2626

27-
#include "coroutines.h"
27+
#include <coroutine>
28+
29+
#include "coroutine.h"
2830
#include "doctest.h"
2931

3032
namespace triton::perfanalyzer {
@@ -41,16 +43,16 @@ TEST_CASE("testing the Coroutine class")
4143
auto coroutine = CoroutineTest();
4244

4345
unsigned rounds = 0;
44-
while (!coroutine.done()) {
45-
coroutine.resume();
46+
while (!coroutine.Done()) {
47+
coroutine.Resume();
4648
rounds++;
4749
}
4850

49-
auto result = coroutine.value();
51+
auto result = coroutine.Value();
5052

5153
CHECK(rounds == 2);
5254
CHECK(result == 42);
53-
CHECK(coroutine.done());
55+
CHECK(coroutine.Done());
5456
}
5557

5658
Coroutine<>
@@ -64,13 +66,13 @@ TEST_CASE("testing the Coroutine class with void")
6466
auto coroutine = CoroutineVoidTest();
6567

6668
unsigned rounds = 0;
67-
while (!coroutine.done()) {
68-
coroutine.resume();
69+
while (!coroutine.Done()) {
70+
coroutine.Resume();
6971
rounds++;
7072
}
7173

7274
CHECK(rounds == 2);
73-
CHECK(coroutine.done());
75+
CHECK(coroutine.Done());
7476
}
7577

7678
Coroutine<int>
@@ -86,16 +88,16 @@ TEST_CASE("testing the Coroutine class with cascading coroutines")
8688
auto coroutine = CascadeCoroutines();
8789

8890
unsigned rounds = 0;
89-
while (!coroutine.done()) {
90-
coroutine.resume();
91+
while (!coroutine.Done()) {
92+
coroutine.Resume();
9193
rounds++;
9294
}
9395

94-
auto result = coroutine.value();
96+
auto result = coroutine.Value();
9597

9698
CHECK(rounds == 4);
9799
CHECK(result == 42);
98-
CHECK(coroutine.done());
100+
CHECK(coroutine.Done());
99101
}
100102

101103
} // namespace triton::perfanalyzer

0 commit comments

Comments
 (0)