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 int32_t* relativeCycles;
27 int32_t* nextEvent;
28};
29
30void mTimingInit(struct mTiming* timing, int32_t* relativeCycles, int32_t* nextEvent);
31void mTimingDeinit(struct mTiming* timing);
32void mTimingClear(struct mTiming* timing);
33void mTimingSchedule(struct mTiming* timing, struct mTimingEvent*, int32_t when);
34void mTimingDeschedule(struct mTiming* timing, struct mTimingEvent*);
35void mTimingTick(struct mTiming* timing, int32_t cycles);
36int32_t mTimingNextEvent(struct mTiming* timing);
37
38#endif