Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Make Synchro PUBLIC
[simgrid.git] / src / simix / Synchro.h
1 /* Copyright (c) 2007-2016. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef _SIMIX_SYNCHRO_HPP
7 #define _SIMIX_SYNCHRO_HPP
8
9 #include <xbt/base.h>
10 #include "simgrid/forward.h"
11
12 #ifdef __cplusplus
13
14 #include <simgrid/simix.hpp>
15
16 namespace simgrid {
17 namespace simix {
18
19   XBT_PUBLIC_CLASS Synchro {
20   public:
21     Synchro();
22     virtual ~Synchro();
23     e_smx_state_t state;               /* State of the synchro */
24     char *name = nullptr;              /* synchro name if any */
25     xbt_fifo_t simcalls;               /* List of simcalls waiting for this synchro */
26     char *category = nullptr;          /* For instrumentation */
27
28     virtual void suspend()=0;
29     virtual void resume()=0;
30     virtual void post() =0; // What to do when a simcall terminates
31
32     void ref();
33     void unref();
34   private:
35     int refcount=1;
36   };
37 }} // namespace simgrid::simix
38 #else /* not C++ */
39
40
41 #endif
42
43 #endif