Deleted Added
sdiff udiff text old ( 13072:f2b83208ab54 ) new ( 13144:61e0f3230787 )
full compact
1/*
2 * Copyright 2018 Google, Inc.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met: redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer;
8 * redistributions in binary form must reproduce the above copyright

--- 17 unchanged lines hidden (view full) ---

26 *
27 * Authors: Gabe Black
28 */
29
30#ifndef __SYSTEMC_CORE_SCHED_EVENT_HH__
31#define __SYSTEMC_CORE_SCHED_EVENT_HH__
32
33#include <functional>
34
35#include "base/types.hh"
36
37namespace sc_gem5
38{
39
40class ScEvent
41{
42 private:
43 std::function<void()> work;
44 Tick _when;
45 bool _scheduled;
46
47 friend class Scheduler;
48
49 void
50 schedule(Tick w)
51 {
52 when(w);
53 _scheduled = true;
54 }
55
56 void deschedule() { _scheduled = false; }
57 public:
58 ScEvent(std::function<void()> work) :
59 work(work), _when(MaxTick), _scheduled(false)
60 {}
61
62 ~ScEvent();
63
64 bool scheduled() { return _scheduled; }
65
66 void when(Tick w) { _when = w; }
67 Tick when() { return _when; }
68
69 void run() { deschedule(); work(); }
70};
71
72} // namespace sc_gem5
73
74#endif // __SYSTEMC_CORE_SCHED_EVENT_HH__