main page
modules
namespaces
classes
files
Gecode home
Generated on Sat Nov 9 2013 19:18:31 for Gecode by
doxygen
1.8.4
gecode
search
worker.hh
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, 2004
8
*
9
* Last modified:
10
* $Date: 2013-10-30 15:42:34 +0100 (Wed, 30 Oct 2013) $ by $Author: schulte $
11
* $Revision: 14037 $
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
#ifndef __GECODE_SEARCH_WORKER_HH__
39
#define __GECODE_SEARCH_WORKER_HH__
40
41
#include <
gecode/search.hh
>
42
43
namespace
Gecode {
namespace
Search {
44
48
class
Worker
:
public
Statistics
{
49
protected
:
51
bool
_stopped
;
53
unsigned
long
int
root_depth
;
54
public
:
56
Worker
(
void
);
58
void
start
(
void
);
60
bool
stop
(
const
Options
& o);
62
bool
stopped
(
void
)
const
;
64
void
reset
(
unsigned
long
int
d
=0);
66
void
stack_depth
(
unsigned
long
int
d
);
68
unsigned
long
int
steal_depth
(
unsigned
long
int
d
)
const
;
69
};
70
71
72
73
forceinline
74
Worker::Worker
(
void
)
75
: _stopped(false), root_depth(0) {}
76
77
forceinline
void
78
Worker::start
(
void
) {
79
_stopped
=
false
;
80
}
81
82
forceinline
bool
83
Worker::stop
(
const
Options
& o) {
84
if
(o.
stop
== NULL)
85
return
false
;
86
_stopped
|= o.
stop
->
stop
(*
this
,o);
87
return
_stopped
;
88
}
89
90
forceinline
bool
91
Worker::stopped
(
void
)
const
{
92
return
_stopped
;
93
}
94
95
forceinline
void
96
Worker::reset
(
unsigned
long
int
d
) {
97
Statistics::reset
();
98
root_depth
=
d
;
99
if
(
depth
< d)
100
depth
=
d
;
101
}
102
103
forceinline
void
104
Worker::stack_depth
(
unsigned
long
int
d
) {
105
if
(
depth
<
root_depth
+ d)
106
depth
=
root_depth
+
d
;
107
}
108
109
forceinline
unsigned
long
int
110
Worker::steal_depth
(
unsigned
long
int
d
)
const
{
111
return
root_depth
+
d
;
112
}
113
114
}}
115
116
#endif
117
118
// STATISTICS: search-other