src/core/timing.h (view raw)
1/* Copyright (c) 2013-2016 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef M_CORE_TIMING
7#define M_CORE_TIMING
8
9#include "util/common.h"
10#include "util/vector.h"
11
12struct mTiming;
13struct mTimingEvent {
14 void* context;
15 void (*callback)(struct mTiming*, void* context, uint32_t);
16 const char* name;
17 uint32_t when;
18};
19
20DECLARE_VECTOR(mTimingEventList, struct mTimingEvent*);
21
22struct mTiming {
23 struct mTimingEventList events;
24
25 uint32_t masterCycles;
26};
27
28void mTimingInit(struct mTiming* timing);
29void mTimingDeinit(struct mTiming* timing);
30void mTimingClear(struct mTiming* timing);
31void mTimingSchedule(struct mTiming* timing, struct mTimingEvent*, int32_t when);
32void mTimingTick(struct mTiming* timing, int32_t cycles);
33int32_t mTimingNextEvent(struct mTiming* timing);
34
35#endif