SST/macro
event_container.h
Go to the documentation of this file.
1 /*
2  * This file is part of SST/macroscale:
3  * The macroscale architecture simulator from the SST suite.
4  * Copyright (c) 2009 Sandia Corporation.
5  * This software is distributed under the BSD License.
6  * Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
7  * the U.S. Government retains certain rights in this software.
8  * For more information, see the LICENSE file in the top
9  * SST/macroscale directory.
10  */
11 
12 #ifndef SSTMAC_BACKENDS_NATIVE_EVENTCONTAINER_H_INCLUDED
13 #define SSTMAC_BACKENDS_NATIVE_EVENTCONTAINER_H_INCLUDED
14 
19 
20 namespace sstmac {
21 namespace native {
22 
23 /**
24  * An event manager base class using standard containers.
25  * The template parameter queue_t is only required to implement the
26  * empty() and size() operations. Methods which need to access or
27  * modify elements, such as do_one_event() and add_event(), are virtual
28  * and must be implemented by a child class, providing flexibility to the
29  * interface that queue_t must provide. In this way, eventmanagers using
30  * both standard containers and container adaptors can share much of their
31  * implementation despite differing access and modification interfaces.
32  */
34 {
35  private:
38 
39  public:
40  /// Goodbye.
41  virtual
42  ~event_container() throw () { }
43 
44  /// Run the eventmanager.
45  /// The eventmanager shall return control when no more messages remain.
46  virtual void
47  run();
48 
49  virtual void
50  init_factory_params(sprockit::sim_parameters* params);
51 
52  protected:
54 
55  virtual void
56  do_next_event();
57 
58  virtual event_queue_entry*
59  pop_next_event() = 0;
60 
61  virtual bool
62  empty() const = 0;
63 
64  /// Called by schedule. Child class must implement.
65  virtual void
67 
68  virtual bool
70  return true;
71  }
72 
73  /// Sentinel to track whether the event handler is running or not.
74  bool running_;
75 
76  /// Time of last event executed.
78 
79 #if SSTMAC_DEBUG_THREAD_EVENTS
80  virtual void open_debug_file(){}
81  virtual void close_debug_file(){}
82 #endif
83 
84  protected:
85  /// Set off the given eventhandler at the given time.
86  void
87  schedule(timestamp start_time, uint32_t seqnum, event_queue_entry* ev);
88 
89  /// Called at end of run(). Calls finish() on finishers_ and calls
90  /// finish_stats().
91  void
92  finish();
93 
94 };
95 
96 }
97 } // end of namespace sstmac
98 
99 
100 
101 #endif
102 
Base type for implementations of an engine that is able to schedule events and advance simulation tim...
Definition: event_manager.h:47
void schedule(timestamp start_time, uint32_t seqnum, event_queue_entry *ev)
Set off the given eventhandler at the given time.
An event manager base class using standard containers.
virtual void add_event(event_queue_entry *ev)=0
Called by schedule. Child class must implement.
virtual void init_factory_params(sprockit::sim_parameters *params)
A basic container for time (subject to future transplant).
Definition: timestamp.h:29
event_container(parallel_runtime *rt)
SUMI = Simulator unified messagine interface It is also the name for a solid ink in Japanese - i...
virtual ~event_container()
Goodbye.
timestamp last_update_sim_
Time of last event executed.
virtual bool empty() const =0
virtual void run()
Run the eventmanager.
void finish()
Called at end of run().
bool running_
Sentinel to track whether the event handler is running or not.
Definition: sst_event.h:67
virtual event_queue_entry * pop_next_event()=0