diff options
author | Andrew Morrow <acm@mongodb.com> | 2014-12-09 11:37:13 -0500 |
---|---|---|
committer | Andrew Morrow <acm@mongodb.com> | 2014-12-09 13:52:50 -0500 |
commit | c26b358aede3e974da05d403cdbcd72d8eac3c60 (patch) | |
tree | 5d6ed34733afdf51c077be910392d5517f5fc23b | |
parent | bc38b5af5637edc8a9aaa9708fcec106b4bc4325 (diff) | |
download | mongo-c26b358aede3e974da05d403cdbcd72d8eac3c60.tar.gz |
SERVER-16478 Remove unused List1 class
-rw-r--r-- | etc/lsan.suppressions | 3 | ||||
-rw-r--r-- | src/mongo/db/repl/topology_coordinator_impl.h | 1 | ||||
-rw-r--r-- | src/mongo/dbtests/threadedtests.cpp | 66 | ||||
-rw-r--r-- | src/mongo/util/concurrency/list.h | 109 |
4 files changed, 0 insertions, 179 deletions
diff --git a/etc/lsan.suppressions b/etc/lsan.suppressions index 7a0254dd41f..2094b82cc5a 100644 --- a/etc/lsan.suppressions +++ b/etc/lsan.suppressions @@ -12,6 +12,3 @@ leak:mongo::setThreadName # lets just ignore v8 for now. If we upgrade to newer v8 # try removing this suppression leak:v8:: - -# List1 is an abomination, as is its test. -leak:ThreadedTests::List1 diff --git a/src/mongo/db/repl/topology_coordinator_impl.h b/src/mongo/db/repl/topology_coordinator_impl.h index e927c89f907..c7dab508ea7 100644 --- a/src/mongo/db/repl/topology_coordinator_impl.h +++ b/src/mongo/db/repl/topology_coordinator_impl.h @@ -37,7 +37,6 @@ #include "mongo/db/repl/repl_coordinator.h" #include "mongo/db/repl/replica_set_config.h" #include "mongo/db/repl/topology_coordinator.h" -#include "mongo/util/concurrency/list.h" #include "mongo/util/time_support.h" namespace mongo { diff --git a/src/mongo/dbtests/threadedtests.cpp b/src/mongo/dbtests/threadedtests.cpp index 8c5f7aaf939..1eb135872b1 100644 --- a/src/mongo/dbtests/threadedtests.cpp +++ b/src/mongo/dbtests/threadedtests.cpp @@ -43,7 +43,6 @@ #include "mongo/stdx/functional.h" #include "mongo/util/concurrency/mvar.h" #include "mongo/util/concurrency/thread_pool.h" -#include "mongo/util/concurrency/list.h" #include "mongo/util/timer.h" #include "mongo/util/concurrency/synchronization.h" #include "mongo/util/concurrency/ticketholder.h" @@ -457,69 +456,6 @@ namespace ThreadedTests { } }; - class List1Test2 : public ThreadedTest<> { - static const int iterations = 1000; // note: a lot of iterations will use a lot of memory as List1 leaks on purpose - class M : public List1<M>::Base { - public: - M(int x) : _x(x) { } - const int _x; - }; - List1<M> l; - public: - void validate() { } - void subthread(int) { - for(int i=0; i < iterations; i++) { - int r = std::rand() % 256; - if( r == 0 ) { - l.orphanAll(); - } - else if( r < 4 ) { - l.push(new M(r)); - } - else { - M *orph = 0; - for( M *m = l.head(); m; m=m->next() ) { - ASSERT( m->_x > 0 && m->_x < 4 ); - if( r > 192 && std::rand() % 8 == 0 ) - orph = m; - } - if( orph ) { - try { - l.orphan(orph); - } - catch(...) { } - } - } - } - } - }; - - class List1Test { - public: - class M : public List1<M>::Base { - ~M(); - public: - M( int x ) { - num = x; - } - int num; - }; - - void run(){ - List1<M> l; - - vector<M*> ms; - for ( int i=0; i<5; i++ ) { - M * m = new M(i); - ms.push_back( m ); - l.push( m ); - } - - // must assert as the item is missing - ASSERT_THROWS( l.orphan( new M( -3 ) ) , UserException ); - } - }; - // we don't use upgrade so that part is not important currently but the other aspects of this test are // interesting; it would be nice to do analogous tests for SimpleRWLock and QLock class UpgradableTest : public ThreadedTest<7> { @@ -871,8 +807,6 @@ namespace ThreadedTests { add< CondSlack >(); add< UpgradableTest >(); - add< List1Test >(); - add< List1Test2 >(); add< IsAtomicWordAtomic<AtomicUInt32> >(); add< IsAtomicWordAtomic<AtomicUInt64> >(); diff --git a/src/mongo/util/concurrency/list.h b/src/mongo/util/concurrency/list.h deleted file mode 100644 index 450cb6f3dce..00000000000 --- a/src/mongo/util/concurrency/list.h +++ /dev/null @@ -1,109 +0,0 @@ -// list.h - -/** -* Copyright (C) 2008 10gen Inc. -* -* This program is free software: you can redistribute it and/or modify -* it under the terms of the GNU Affero General Public License, version 3, -* as published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU Affero General Public License for more details. -* -* You should have received a copy of the GNU Affero General Public License -* along with this program. If not, see <http://www.gnu.org/licenses/>. -* -* As a special exception, the copyright holders give permission to link the -* code of portions of this program with the OpenSSL library under certain -* conditions as described in each individual source file and distribute -* linked combinations including the program with the OpenSSL library. You -* must comply with the GNU Affero General Public License in all respects -* for all of the code used other than as permitted herein. If you modify -* file(s) with this exception, you may extend this exception to your -* version of the file(s), but you are not obligated to do so. If you do not -* wish to do so, delete this exception statement from your version. If you -* delete this exception statement from all source files in the program, -* then also delete it in the license file. -*/ - -#pragma once - -namespace mongo { - - /* DON'T USE THIS. it was a dumb idea. - - this class uses a mutex for writes, but not for reads. - we can get fancier later... - - struct Member : public List1<Member>::Base { - const char *host; - int port; - }; - List1<Member> _members; - _members.head()->next(); - - */ - template<typename T> - class List1 : boost::noncopyable { - public: - /* next() and head() return 0 at end of list */ - - List1() : _head(0), _m("List1"), _orphans(0) { } - - class Base { - friend class List1; - T *_next; - public: - Base() : _next(0){} - ~Base() { wassert(false); } // we never want this to happen - T* next() const { return _next; } - }; - - /** note this is safe: - - T* p = mylist.head(); - if( p ) - use(p); - - and this is not: - - if( mylist.head() ) - use( mylist.head() ); // could become 0 - */ - T* head() const { return (T*) _head; } - - void push(T* t) { - verify( t->_next == 0 ); - scoped_lock lk(_m); - t->_next = (T*) _head; - _head = t; - } - - // intentionally leaks. - void orphanAll() { - scoped_lock lk(_m); - _head = 0; - } - - /* t is not deleted, but is removed from the list. (orphaned) */ - void orphan(T* t) { - scoped_lock lk(_m); - T *&prev = (T*&) _head; - T *n = prev; - while( n != t ) { - uassert( 14050 , "List1: item to orphan not in list", n ); - prev = n->_next; - n = prev; - } - prev = t->_next; - } - - private: - volatile T *_head; - mongo::mutex _m; - int _orphans; - }; - -}; |