Skip to content
Commits on Source (5)
From: Alpar Juttner <alpar@cs.elte.hu>
Date: Wed, 6 May 2015 16:01:26 +0200
Subject: Threadsafe CplexEnv (#473)
---
lemon/cplex.cc | 43 ++++++++++++++++++++++++++++++-------------
lemon/cplex.h | 5 +++++
2 files changed, 35 insertions(+), 13 deletions(-)
diff --git a/lemon/cplex.cc b/lemon/cplex.cc
index 029a3ef..4d519fd 100644
--- a/lemon/cplex.cc
+++ b/lemon/cplex.cc
@@ -37,37 +37,54 @@ namespace lemon {
}
}
+ void CplexEnv::incCnt()
+ {
+ _cnt_lock->lock();
+ ++(*_cnt);
+ _cnt_lock->unlock();
+ }
+
+ void CplexEnv::decCnt()
+ {
+ _cnt_lock->lock();
+ --(*_cnt);
+ if (*_cnt == 0) {
+ delete _cnt;
+ _cnt_lock->unlock();
+ delete _cnt_lock;
+ CPXcloseCPLEX(&_env);
+ }
+ else _cnt_lock->unlock();
+ }
+
CplexEnv::CplexEnv() {
int status;
- _cnt = new int;
- (*_cnt) = 1;
_env = CPXopenCPLEX(&status);
- if (_env == 0) {
- delete _cnt;
- _cnt = 0;
+ if (_env == 0)
throw LicenseError(status);
- }
+ _cnt = new int;
+ (*_cnt) = 1;
+ _cnt_lock = new bits::Lock;
}
CplexEnv::CplexEnv(const CplexEnv& other) {
_env = other._env;
_cnt = other._cnt;
- ++(*_cnt);
+ _cnt_lock = other._cnt_lock;
+ incCnt();
}
CplexEnv& CplexEnv::operator=(const CplexEnv& other) {
+ decCnt();
_env = other._env;
_cnt = other._cnt;
- ++(*_cnt);
+ _cnt_lock = other._cnt_lock;
+ incCnt();
return *this;
}
CplexEnv::~CplexEnv() {
- --(*_cnt);
- if (*_cnt == 0) {
- delete _cnt;
- CPXcloseCPLEX(&_env);
- }
+ decCnt();
}
CplexBase::CplexBase() : LpBase() {
diff --git a/lemon/cplex.h b/lemon/cplex.h
index c17e792..2397f9f 100644
--- a/lemon/cplex.h
+++ b/lemon/cplex.h
@@ -23,6 +23,7 @@
///\brief Header of the LEMON-CPLEX lp solver interface.
#include <lemon/lp_base.h>
+#include <lemon/bits/lock.h>
struct cpxenv;
struct cpxlp;
@@ -40,7 +41,11 @@ namespace lemon {
private:
cpxenv* _env;
mutable int* _cnt;
+ mutable bits::Lock* _cnt_lock;
+ void incCnt();
+ void decCnt();
+
public:
/// \brief This exception is thrown when the license check is not
From: Alpar Juttner <alpar@cs.elte.hu>
Date: Fri, 22 May 2015 17:47:18 +0200
Subject: Fix wrong iteration in ListGraph snapshot, part II. (#598)
---
lemon/list_graph.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/lemon/list_graph.h b/lemon/list_graph.h
index 2a236cf..1964f7d 100644
--- a/lemon/list_graph.h
+++ b/lemon/list_graph.h
@@ -2299,7 +2299,7 @@ namespace lemon {
snapshot.addNode(node);
}
virtual void add(const std::vector<Node>& nodes) {
- for (int i = nodes.size() - 1; i >= 0; ++i) {
+ for (int i = nodes.size() - 1; i >= 0; --i) {
snapshot.addNode(nodes[i]);
}
}
@@ -2349,7 +2349,7 @@ namespace lemon {
snapshot.addEdge(edge);
}
virtual void add(const std::vector<Edge>& edges) {
- for (int i = edges.size() - 1; i >= 0; ++i) {
+ for (int i = edges.size() - 1; i >= 0; --i) {
snapshot.addEdge(edges[i]);
}
}
From: Peter Kovacs <kpeter@inf.elte.hu>
Date: Fri, 2 Oct 2015 17:41:28 +0200
Subject: Add missing #include to capacity_scaling.h (#600)
---
lemon/capacity_scaling.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/lemon/capacity_scaling.h b/lemon/capacity_scaling.h
index ca64b56..8acd5fe 100644
--- a/lemon/capacity_scaling.h
+++ b/lemon/capacity_scaling.h
@@ -27,6 +27,7 @@
#include <vector>
#include <limits>
#include <lemon/core.h>
+#include <lemon/maps.h>
#include <lemon/bin_heap.h>
namespace lemon {
From: Peter Kovacs <kpeter@inf.elte.hu>
Date: Thu, 22 Mar 2018 18:46:56 +0100
Subject: Add missing break statement to dimacs-solver (#609)
---
tools/dimacs-solver.cc | 3 +++
1 file changed, 3 insertions(+)
diff --git a/tools/dimacs-solver.cc b/tools/dimacs-solver.cc
index 60da233..0ccbcd0 100644
--- a/tools/dimacs-solver.cc
+++ b/tools/dimacs-solver.cc
@@ -222,11 +222,13 @@ int main(int argc, const char *argv[]) {
if (!output) {
throw IoError("Cannot open the file for writing", ap.files()[1]);
}
+ // fall through
case 1:
input.open(ap.files()[0].c_str());
if (!input) {
throw IoError("File cannot be found", ap.files()[0]);
}
+ // fall through
case 0:
break;
default:
@@ -251,6 +253,7 @@ int main(int argc, const char *argv[]) {
break;
case DimacsDescriptor::SP:
std::cout << "sp";
+ break;
case DimacsDescriptor::MAT:
std::cout << "mat";
break;
dynamic_lib.patch
fix_libname.patch
0002-Threadsafe-CplexEnv-473.patch
0003-Fix-wrong-iteration-in-ListGraph-snapshot-part-II.-5.patch
0004-Add-missing-include-to-capacity_scaling.h-600.patch
0005-Add-missing-break-statement-to-dimacs-solver-609.patch
......@@ -22,13 +22,16 @@ override_dh_install:
# from other package - no idea how to do this so use symlink instead
find debian -name jquery.js -delete
cp -a obj-*/lemon/liblemon_static.a debian/tmp/usr/lib/liblemon.a
# Modify CMake config file to add multiarch
sed -i 's:usr/lib:usr/lib/$(DEB_HOST_MULTIARCH):' debian/tmp/usr/share/lemon/cmake/*
d-shlibmove --commit \
--multiarch \
--devunversioned \
--exclude-la \
--override "s/libglpk40-dev/libglpk-dev/" \
--movedev debian/tmp/usr/include/* usr/include \
--movedev "debian/tmp/usr/lib/pkgconfig/*.pc" usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig \
--movedev "debian/tmp/usr/share/lemon/cmake/*" usr/lib/cmake \
--movedev "debian/tmp/usr/share/lemon/cmake/*" usr/lib/$(DEB_HOST_MULTIARCH)/cmake/lemon \
debian/tmp/usr/lib/*.so
override_dh_installchangelogs:
......