Generated on Thu Mar 16 2017 03:24:23 for Gecode by doxygen 1.8.13
tracer.hpp
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 2; indent-tabs-mode: nil -*- */
2 /*
3  * Main authors:
4  * Christian Schulte <schulte@gecode.org>
5  *
6  * Copyright:
7  * Christian Schulte, 2016
8  *
9  * Last modified:
10  * $Date: 2016-05-30 21:05:33 +0200 (Mon, 30 May 2016) $ by $Author: schulte $
11  * $Revision: 15094 $
12  *
13  * This file is part of Gecode, the generic constraint
14  * development environment:
15  * http://www.gecode.org
16  *
17  * Permission is hereby granted, free of charge, to any person obtaining
18  * a copy of this software and associated documentation files (the
19  * "Software"), to deal in the Software without restriction, including
20  * without limitation the rights to use, copy, modify, merge, publish,
21  * distribute, sublicense, and/or sell copies of the Software, and to
22  * permit persons to whom the Software is furnished to do so, subject to
23  * the following conditions:
24  *
25  * The above copyright notice and this permission notice shall be
26  * included in all copies or substantial portions of the Software.
27  *
28  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
30  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
32  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
33  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
34  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35  *
36  */
37 
38 namespace Gecode {
39 
41  class TracerBase : public HeapAllocated {
42  protected:
45  static Support::Mutex m;
46  };
47 
48  template<class View> class TraceRecorder;
49 
54  template<class View>
55  class Tracer : public TracerBase {
56  template<class ViewForTraceRecorder> friend class TraceRecorder;
57  private:
64  void _init(const Space& home, const TraceRecorder<View>& t);
71  void _prune(const Space& home, const TraceRecorder<View>& t,
72  const ExecInfo& ei,
73  int i, typename TraceTraits<View>::TraceDelta& d);
79  void _fix(const Space& home, const TraceRecorder<View>& t);
85  void _done(const Space& home, const TraceRecorder<View>& t);
86  public:
88  Tracer(void);
95  virtual void init(const Space& home,
96  const TraceRecorder<View>& t) = 0;
106  virtual void prune(const Space& home,
107  const TraceRecorder<View>& t,
108  const ExecInfo& ei,
109  int i, typename TraceTraits<View>::TraceDelta& d) = 0;
117  virtual void fix(const Space& home,
118  const TraceRecorder<View>& t) = 0;
125  virtual void done(const Space& home,
126  const TraceRecorder<View>& t) = 0;
128  virtual ~Tracer(void);
129  };
130 
131 
132  template<class View>
135 
136  template<class View>
137  forceinline void
138  Tracer<View>::_init(const Space& home, const TraceRecorder<View>& t) {
139  m.acquire();
140  init(home,t);
141  m.release();
142  }
143  template<class View>
144  forceinline void
145  Tracer<View>::_prune(const Space& home, const TraceRecorder<View>& t,
146  const ExecInfo& ei,
147  int i, typename TraceTraits<View>::TraceDelta& d) {
148  m.acquire();
149  prune(home,t,ei,i,d);
150  m.release();
151  }
152  template<class View>
153  forceinline void
154  Tracer<View>::_fix(const Space& home, const TraceRecorder<View>& t) {
155  m.acquire();
156  fix(home,t);
157  m.release();
158  }
159  template<class View>
160  forceinline void
161  Tracer<View>::_done(const Space& home, const TraceRecorder<View>& t) {
162  m.acquire();
163  done(home,t);
164  m.release();
165  }
166  template<class View>
169 
170 }
171 
172 // STATISTICS: kernel-other
NodeType t
Type of node.
Definition: bool-expr.cpp:234
virtual ~Tracer(void)
Destructor.
Definition: tracer.hpp:168
Class to provide synchronization.
Definition: tracer.hpp:41
Tracer(void)
Constructor.
Definition: tracer.hpp:134
void acquire(void)
Acquire the mutex and possibly block.
Definition: none.hpp:46
Computation spaces.
Definition: core.hpp:1672
ExecStatus prune(Space &home, ViewArray< VX > &x, ConstIntView)
Definition: rel.hpp:257
static Support::Mutex m
Mutex to provide synchronization.
Definition: tracer.hpp:45
A mutex for mutual exclausion among several threads.
Definition: thread.hpp:99
Gecode::IntSet d(v, 7)
void release(void)
Release the mutex.
Definition: none.hpp:52
Gecode::IntArgs i(4, 1, 2, 3, 4)
Propagator for recording trace information.
#define GECODE_KERNEL_EXPORT
Definition: kernel.hh:70
Execution information.
Definition: core.hpp:957
Traits for tracing.
#define forceinline
Definition: config.hpp:173
Tracer that process trace information.
Definition: tracer.hpp:55
Gecode toplevel namespace
Base class for heap allocated objects.
Definition: heap.hpp:344