From: Matthias Maier Date: Thu, 13 Dec 2012 17:59:20 +0000 (+0000) Subject: Avoid usage of deprecated methods and classes in source/base X-Git-Tag: v8.0.0~1079^2~193^2~29 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2a313ae5a92f9563d9eeeaece6f8054114d6314;p=dealii.git Avoid usage of deprecated methods and classes in source/base ThreadMutex -> Mutex Implement vector::scale in operator*= Drop deprecated attribute for Logstream::push/pop for now git-svn-id: https://svn.dealii.org/branches/branch_deprecated@27807 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/include/deal.II/base/logstream.h b/deal.II/include/deal.II/base/logstream.h index 83a98105fd..cb50979e38 100644 --- a/deal.II/include/deal.II/base/logstream.h +++ b/deal.II/include/deal.II/base/logstream.h @@ -216,14 +216,14 @@ public: * colon and there is a double * colon after the last prefix. */ - void push (const std::string &text) DEAL_II_DEPRECATED; + void push (const std::string &text); /** * @deprecated Use Prefix instead * * Remove the last prefix. */ - void pop () DEAL_II_DEPRECATED; + void pop (); /** * Maximum number of levels to be diff --git a/deal.II/include/deal.II/lac/vector.h b/deal.II/include/deal.II/lac/vector.h index bba0d25544..92d57362a6 100644 --- a/deal.II/include/deal.II/lac/vector.h +++ b/deal.II/include/deal.II/lac/vector.h @@ -800,7 +800,10 @@ public: * operator *= and * operator /= instead. */ - void scale (const Number factor) DEAL_II_DEPRECATED; + void scale (const Number factor) DEAL_II_DEPRECATED + { + this->operator *= (factor); + } /** @@ -1265,19 +1268,6 @@ Number &Vector::operator[] (const unsigned int i) -template -inline -Vector &Vector::operator *= (const Number factor) -{ - - Assert (numbers::is_finite(factor),ExcNumberNotFinite()); - - scale (factor); - return *this; -} - - - template inline Vector & diff --git a/deal.II/include/deal.II/lac/vector.templates.h b/deal.II/include/deal.II/lac/vector.templates.h index 1c1943a7de..9587ea7fb3 100644 --- a/deal.II/include/deal.II/lac/vector.templates.h +++ b/deal.II/include/deal.II/lac/vector.templates.h @@ -431,7 +431,7 @@ Vector >::operator = (const std::complex s) template void -Vector::scale (const Number factor) +Vector &Vector::operator *= (const Number factor) { Assert (numbers::is_finite(factor),ExcNumberNotFinite()); @@ -442,6 +442,8 @@ Vector::scale (const Number factor) val, (factor*boost::lambda::_1), internal::Vector::minimum_parallel_grain_size); + + return *this; } diff --git a/deal.II/source/base/function_derivative.cc b/deal.II/source/base/function_derivative.cc index 09b8bfd80e..cfa5c9f20a 100644 --- a/deal.II/source/base/function_derivative.cc +++ b/deal.II/source/base/function_derivative.cc @@ -130,7 +130,7 @@ FunctionDerivative::vector_value ( result.add(-8., aux); f.vector_value(p+incr[0], aux); result.add(8., aux); - result.scale(1./(12*h)); + result/=(12.*h); return; default: Assert(false, ExcInvalidFormula()); diff --git a/deal.II/source/base/logstream.cc b/deal.II/source/base/logstream.cc index 8fb571cb3d..67852cb616 100644 --- a/deal.II/source/base/logstream.cc +++ b/deal.II/source/base/logstream.cc @@ -35,8 +35,8 @@ DEAL_II_NAMESPACE_OPEN namespace { - Threads::ThreadMutex log_lock; - Threads::ThreadMutex write_lock; + Threads::Mutex log_lock; + Threads::Mutex write_lock; } @@ -151,7 +151,7 @@ LogStream::~LogStream() void LogStream::test_mode(bool on) { - Threads::ThreadMutex::ScopedLock lock(log_lock); + Threads::Mutex::ScopedLock lock(log_lock); if (on) { double_threshold = 1.e-10; @@ -180,7 +180,7 @@ LogStream::operator<< (std::ostream& (*p) (std::ostream &)) std::ostream & (* const p_endl) (std::ostream &) = &std::endl; if (p == p_endl) { - Threads::ThreadMutex::ScopedLock lock(write_lock); + Threads::Mutex::ScopedLock lock(write_lock); print_line_head(); std::ostringstream &stream = get_stream(); if (prefixes.size() <= std_depth) @@ -200,7 +200,7 @@ std::ostringstream & LogStream::get_stream() { //TODO: use a ThreadLocalStorage object here - Threads::ThreadMutex::ScopedLock lock(log_lock); + Threads::Mutex::ScopedLock lock(log_lock); const unsigned int id = Threads::this_thread_id(); // if necessary allocate a stream object @@ -217,7 +217,7 @@ LogStream::get_stream() void LogStream::attach(std::ostream &o) { - Threads::ThreadMutex::ScopedLock lock(log_lock); + Threads::Mutex::ScopedLock lock(log_lock); file = &o; o.setf(std::ios::showpoint | std::ios::left); o << dealjobid(); @@ -226,14 +226,14 @@ LogStream::attach(std::ostream &o) void LogStream::detach () { - Threads::ThreadMutex::ScopedLock lock(log_lock); + Threads::Mutex::ScopedLock lock(log_lock); file = 0; } void LogStream::log_cerr () { - Threads::ThreadMutex::ScopedLock lock(log_lock); + Threads::Mutex::ScopedLock lock(log_lock); if (old_cerr == 0) { old_cerr = std::cerr.rdbuf(file->rdbuf()); @@ -278,7 +278,7 @@ LogStream::get_prefix() const void LogStream::push (const std::string &text) { - Threads::ThreadMutex::ScopedLock lock(log_lock); + Threads::Mutex::ScopedLock lock(log_lock); std::string pre=prefixes.top(); pre += text; pre += std::string(":"); @@ -288,7 +288,7 @@ LogStream::push (const std::string &text) void LogStream::pop () { - Threads::ThreadMutex::ScopedLock lock(log_lock); + Threads::Mutex::ScopedLock lock(log_lock); if (prefixes.size() > 1) prefixes.pop(); } @@ -297,7 +297,7 @@ void LogStream::pop () unsigned int LogStream::depth_console (const unsigned int n) { - Threads::ThreadMutex::ScopedLock lock(log_lock); + Threads::Mutex::ScopedLock lock(log_lock); const unsigned int h = std_depth; std_depth = n; return h; @@ -307,7 +307,7 @@ LogStream::depth_console (const unsigned int n) unsigned int LogStream::depth_file (const unsigned int n) { - Threads::ThreadMutex::ScopedLock lock(log_lock); + Threads::Mutex::ScopedLock lock(log_lock); const unsigned int h = file_depth; file_depth = n; return h; @@ -317,7 +317,7 @@ LogStream::depth_file (const unsigned int n) void LogStream::threshold_double (const double t) { - Threads::ThreadMutex::ScopedLock lock(log_lock); + Threads::Mutex::ScopedLock lock(log_lock); double_threshold = t; } @@ -325,7 +325,7 @@ LogStream::threshold_double (const double t) void LogStream::threshold_float (const float t) { - Threads::ThreadMutex::ScopedLock lock(log_lock); + Threads::Mutex::ScopedLock lock(log_lock); float_threshold = t; } @@ -333,7 +333,7 @@ LogStream::threshold_float (const float t) bool LogStream::log_execution_time (const bool flag) { - Threads::ThreadMutex::ScopedLock lock(log_lock); + Threads::Mutex::ScopedLock lock(log_lock); const bool h = print_utime; print_utime = flag; return h; @@ -343,7 +343,7 @@ LogStream::log_execution_time (const bool flag) bool LogStream::log_time_differences (const bool flag) { - Threads::ThreadMutex::ScopedLock lock(log_lock); + Threads::Mutex::ScopedLock lock(log_lock); const bool h = diff_utime; diff_utime = flag; return h; @@ -353,7 +353,7 @@ LogStream::log_time_differences (const bool flag) bool LogStream::log_thread_id (const bool flag) { - Threads::ThreadMutex::ScopedLock lock(log_lock); + Threads::Mutex::ScopedLock lock(log_lock); const bool h = print_thread_id; print_thread_id = flag; return h; diff --git a/deal.II/source/base/polynomial.cc b/deal.II/source/base/polynomial.cc index 7f1a627bcb..0664ce5e2a 100644 --- a/deal.II/source/base/polynomial.cc +++ b/deal.II/source/base/polynomial.cc @@ -34,7 +34,7 @@ DEAL_II_NAMESPACE_OPEN // more fine-grained solution namespace { - Threads::ThreadMutex coefficients_lock; + Threads::Mutex coefficients_lock; } @@ -888,7 +888,7 @@ namespace Polynomials // operation of this function; // for this, acquire the lock // until we quit this function - Threads::ThreadMutex::ScopedLock lock(coefficients_lock); + Threads::Mutex::ScopedLock lock(coefficients_lock); // The first 2 coefficients are hard-coded if (k==0) @@ -1021,7 +1021,7 @@ namespace Polynomials // then get a pointer to the array // of coefficients. do that in a MT // safe way - Threads::ThreadMutex::ScopedLock lock (coefficients_lock); + Threads::Mutex::ScopedLock lock (coefficients_lock); return *shifted_coefficients[k]; } @@ -1153,7 +1153,7 @@ namespace Polynomials // of this function // for this, acquire the lock // until we quit this function - Threads::ThreadMutex::ScopedLock lock(coefficients_lock); + Threads::Mutex::ScopedLock lock(coefficients_lock); // The first 2 coefficients // are hard-coded @@ -1288,7 +1288,7 @@ namespace Polynomials // then get a pointer to the array // of coefficients. do that in a MT // safe way - Threads::ThreadMutex::ScopedLock lock (coefficients_lock); + Threads::Mutex::ScopedLock lock (coefficients_lock); return *recursive_coefficients[k]; } diff --git a/deal.II/source/base/polynomials_raviart_thomas.cc b/deal.II/source/base/polynomials_raviart_thomas.cc index aa0ee7137f..367b2443e1 100644 --- a/deal.II/source/base/polynomials_raviart_thomas.cc +++ b/deal.II/source/base/polynomials_raviart_thomas.cc @@ -78,8 +78,8 @@ PolynomialsRaviartThomas::compute (const Point &unit_point, // deal.II/create_mass_matrix_05) // will start to produce random // results in multithread mode - static Threads::ThreadMutex mutex; - Threads::ThreadMutex::ScopedLock lock(mutex); + static Threads::Mutex mutex; + Threads::Mutex::ScopedLock lock(mutex); static std::vector p_values; static std::vector > p_grads; diff --git a/deal.II/source/base/subscriptor.cc b/deal.II/source/base/subscriptor.cc index 6d0bd775de..bb4638541a 100644 --- a/deal.II/source/base/subscriptor.cc +++ b/deal.II/source/base/subscriptor.cc @@ -34,7 +34,7 @@ namespace // operates on a per-object base (in which case we would have to // include the huge file into the // file). - Threads::ThreadMutex subscription_lock; + Threads::Mutex subscription_lock; } @@ -144,7 +144,7 @@ void Subscriptor::do_subscribe (const char *id) const #ifdef DEBUG if (object_info == 0) object_info = &typeid(*this); - Threads::ThreadMutex::ScopedLock lock (subscription_lock); + Threads::Mutex::ScopedLock lock (subscription_lock); ++counter; #ifndef DEAL_II_USE_MT @@ -171,7 +171,7 @@ void Subscriptor::do_unsubscribe (const char *id) const if (counter == 0) return; - Threads::ThreadMutex::ScopedLock lock (subscription_lock); + Threads::Mutex::ScopedLock lock (subscription_lock); --counter; #ifndef DEAL_II_USE_MT diff --git a/deal.II/source/base/thread_management.cc b/deal.II/source/base/thread_management.cc index de0ff51ff2..da4db796a2 100644 --- a/deal.II/source/base/thread_management.cc +++ b/deal.II/source/base/thread_management.cc @@ -34,12 +34,12 @@ namespace Threads // counter and access mutex for the // number of threads volatile unsigned int n_existing_threads_counter = 1; - ThreadMutex n_existing_threads_mutex; + Mutex n_existing_threads_mutex; void register_thread () { - ThreadMutex::ScopedLock lock (n_existing_threads_mutex); + Mutex::ScopedLock lock (n_existing_threads_mutex); ++n_existing_threads_counter; } @@ -47,7 +47,7 @@ namespace Threads void deregister_thread () { - ThreadMutex::ScopedLock lock (n_existing_threads_mutex); + Mutex::ScopedLock lock (n_existing_threads_mutex); --n_existing_threads_counter; Assert (n_existing_threads_counter >= 1, ExcInternalError()); @@ -127,7 +127,7 @@ namespace Threads unsigned int n_existing_threads () { - ThreadMutex::ScopedLock lock (internal::n_existing_threads_mutex); + Mutex::ScopedLock lock (internal::n_existing_threads_mutex); return internal::n_existing_threads_counter; } diff --git a/deal.II/source/base/timer.cc b/deal.II/source/base/timer.cc index ca6aca302e..633b1a32d7 100644 --- a/deal.II/source/base/timer.cc +++ b/deal.II/source/base/timer.cc @@ -337,7 +337,7 @@ TimerOutput::~TimerOutput() void TimerOutput::enter_subsection (const std::string §ion_name) { - Threads::ThreadMutex::ScopedLock lock (mutex); + Threads::Mutex::ScopedLock lock (mutex); Assert (section_name.empty() == false, ExcMessage ("Section string is empty.")); @@ -369,7 +369,7 @@ TimerOutput::leave_subsection (const std::string §ion_name) Assert (!active_sections.empty(), ExcMessage("Cannot exit any section because none has been entered!")); - Threads::ThreadMutex::ScopedLock lock (mutex); + Threads::Mutex::ScopedLock lock (mutex); if (section_name != "") {