diff options
author | Hari Khalsa <hkhalsa@10gen.com> | 2014-05-16 16:40:52 -0400 |
---|---|---|
committer | Hari Khalsa <hkhalsa@10gen.com> | 2014-05-16 17:18:07 -0400 |
commit | 33e3abd0c81e2cb70f5b8159818dc1ec685d7b34 (patch) | |
tree | d44898a4963039a762868c5efca41275f2c5413c /src/mongo/db | |
parent | 26ce741fb87fb9a9b784fa1e3ea88a713b802bc6 (diff) | |
download | mongo-33e3abd0c81e2cb70f5b8159818dc1ec685d7b34.tar.gz |
SERVER-13635 remove dead code
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/client.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/commands/compact.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/commands/touch.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/curop-inl.h | 29 | ||||
-rw-r--r-- | src/mongo/db/dbcommands_admin.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/driverHelpers.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/filever.h | 42 | ||||
-rw-r--r-- | src/mongo/db/flushtest.cpp | 164 | ||||
-rw-r--r-- | src/mongo/db/instance.h | 2 | ||||
-rw-r--r-- | src/mongo/db/javatest.cpp | 36 | ||||
-rw-r--r-- | src/mongo/db/minilex.h | 176 | ||||
-rw-r--r-- | src/mongo/db/pdfile.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/storage/mmap_v1/dur_commitjob.cpp | 1 | ||||
-rw-r--r-- | src/mongo/db/storage/mmap_v1/dur_commitjob.h | 1 | ||||
-rw-r--r-- | src/mongo/db/taskqueue.h | 121 | ||||
-rw-r--r-- | src/mongo/db/tests.cpp | 83 |
16 files changed, 7 insertions, 660 deletions
diff --git a/src/mongo/db/client.cpp b/src/mongo/db/client.cpp index 5d1a1494901..b9505375194 100644 --- a/src/mongo/db/client.cpp +++ b/src/mongo/db/client.cpp @@ -49,7 +49,7 @@ #include "mongo/db/auth/privilege.h" #include "mongo/db/db.h" #include "mongo/db/commands.h" -#include "mongo/db/curop-inl.h" +#include "mongo/db/curop.h" #include "mongo/db/kill_current_op.h" #include "mongo/db/dbwebserver.h" #include "mongo/db/instance.h" diff --git a/src/mongo/db/commands/compact.cpp b/src/mongo/db/commands/compact.cpp index 14af4c56d03..4e51b92e930 100644 --- a/src/mongo/db/commands/compact.cpp +++ b/src/mongo/db/commands/compact.cpp @@ -38,7 +38,7 @@ #include "mongo/db/commands.h" #include "mongo/db/catalog/database.h" #include "mongo/db/d_concurrency.h" -#include "mongo/db/curop-inl.h" +#include "mongo/db/curop.h" #include "mongo/db/index_builder.h" #include "mongo/db/jsobj.h" #include "mongo/db/kill_current_op.h" diff --git a/src/mongo/db/commands/touch.cpp b/src/mongo/db/commands/touch.cpp index e44a84b6bae..841a738abf2 100644 --- a/src/mongo/db/commands/touch.cpp +++ b/src/mongo/db/commands/touch.cpp @@ -42,7 +42,7 @@ #include "mongo/db/catalog/collection.h" #include "mongo/db/catalog/database.h" #include "mongo/db/commands.h" -#include "mongo/db/curop-inl.h" +#include "mongo/db/curop.h" #include "mongo/db/d_concurrency.h" #include "mongo/db/index/index_descriptor.h" #include "mongo/db/jsobj.h" diff --git a/src/mongo/db/curop-inl.h b/src/mongo/db/curop-inl.h deleted file mode 100644 index dba3454c70a..00000000000 --- a/src/mongo/db/curop-inl.h +++ /dev/null @@ -1,29 +0,0 @@ -/** -* Copyright (C) 2012 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. -*/ - -#include "mongo/db/curop.h" diff --git a/src/mongo/db/dbcommands_admin.cpp b/src/mongo/db/dbcommands_admin.cpp index 736e932d4d3..be36c4d6445 100644 --- a/src/mongo/db/dbcommands_admin.cpp +++ b/src/mongo/db/dbcommands_admin.cpp @@ -48,7 +48,7 @@ #include "mongo/db/auth/action_type.h" #include "mongo/db/auth/privilege.h" #include "mongo/db/commands.h" -#include "mongo/db/curop-inl.h" +#include "mongo/db/curop.h" #include "mongo/db/index/index_access_method.h" #include "mongo/db/index/index_descriptor.h" #include "mongo/db/jsobj.h" diff --git a/src/mongo/db/driverHelpers.cpp b/src/mongo/db/driverHelpers.cpp index f98fa46cbb3..5f140b6e069 100644 --- a/src/mongo/db/driverHelpers.cpp +++ b/src/mongo/db/driverHelpers.cpp @@ -43,7 +43,7 @@ #include "mongo/db/auth/action_type.h" #include "mongo/db/auth/privilege.h" #include "mongo/db/commands.h" -#include "mongo/db/curop-inl.h" +#include "mongo/db/curop.h" #include "mongo/db/jsobj.h" #include "mongo/db/pdfile.h" #include "mongo/scripting/engine.h" diff --git a/src/mongo/db/filever.h b/src/mongo/db/filever.h deleted file mode 100644 index 05b58c1734c..00000000000 --- a/src/mongo/db/filever.h +++ /dev/null @@ -1,42 +0,0 @@ -/* filever.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 { - - inline void checkDataFileVersion(NamespaceDetails& d) { - } - - inline void checkIndexFileVersion(NamespaceDetails& d) { - } - -} - diff --git a/src/mongo/db/flushtest.cpp b/src/mongo/db/flushtest.cpp deleted file mode 100644 index e057fe870c3..00000000000 --- a/src/mongo/db/flushtest.cpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (C) 2010 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. - */ - -#include "mongo/pch.h" - -#include <fcntl.h> -#include <stdio.h> - -#include "mongo/util/goodies.h" - -namespace mongo { - -#if defined(F_FULLFSYNC) - void fullsync(int f) { - fcntl( f, F_FULLFSYNC ); - } -#else - void fullsync(int f) { - fdatasync(f); - } -#endif - - int main(int argc, char* argv[], char *envp[] ) { - cout << "hello" << endl; - - FILE *f = fopen("/data/db/temptest", "a"); - - if ( f == 0 ) { - cout << "can't open file\n"; - return 1; - } - - { - Timer t; - for ( int i = 0; i < 50000; i++ ) - fwrite("abc", 3, 1, f); - cout << "small writes: " << t.millis() << "ms" << endl; - } - - { - Timer t; - for ( int i = 0; i < 10000; i++ ) { - fwrite("abc", 3, 1, f); - fflush(f); - fsync( fileno( f ) ); - } - int ms = t.millis(); - cout << "flush: " << ms << "ms, " << ms / 10000.0 << "ms/request" << endl; - } - - { - Timer t; - for ( int i = 0; i < 500; i++ ) { - fwrite("abc", 3, 1, f); - fflush(f); - fsync( fileno( f ) ); - sleepmillis(2); - } - int ms = t.millis() - 500 * 2; - cout << "flush with sleeps: " << ms << "ms, " << ms / 500.0 << "ms/request" << endl; - } - - char buf[8192]; - for ( int pass = 0; pass < 2; pass++ ) { - cout << "pass " << pass << endl; - { - Timer t; - int n = 500; - for ( int i = 0; i < n; i++ ) { - if ( pass == 0 ) - fwrite("abc", 3, 1, f); - else - fwrite(buf, 8192, 1, f); - buf[0]++; - fflush(f); - fullsync(fileno(f)); - } - int ms = t.millis(); - cout << "fullsync: " << ms << "ms, " << ms / ((double) n) << "ms/request" << endl; - } - - { - Timer t; - for ( int i = 0; i < 500; i++ ) { - if ( pass == 0 ) - fwrite("abc", 3, 1, f); - else - fwrite(buf, 8192, 1, f); - buf[0]++; - fflush(f); - fullsync(fileno(f)); - sleepmillis(2); - } - int ms = t.millis() - 2 * 500; - cout << "fullsync with sleeps: " << ms << "ms, " << ms / 500.0 << "ms/request" << endl; - } - } - - // without growing - { - fclose(f); - /* try from beginning of the file, where we aren't appending and changing the file length, - to see if this is faster as the directory entry then doesn't have to be flushed (if noatime in effect). - */ - f = fopen("/data/db/temptest", "r+"); - Timer t; - int n = 500; - for ( int i = 0; i < n; i++ ) { - fwrite("xyz", 3, 1, f); - fflush(f); - fullsync(fileno(f)); - } - int ms = t.millis(); - cout << "fullsync without growing: " << ms << "ms, " << ms / ((double) n) << "ms/request" << endl; - } - - // without growing, with delay - { - fclose(f); - /* try from beginning of the file, where we aren't appending and changing the file length, - to see if this is faster as the directory entry then doesn't have to be flushed (if noatime in effect). - */ - f = fopen("/data/db/temptest", "r+"); - Timer t; - int n = 500; - for ( int i = 0; i < n; i++ ) { - fwrite("xyz", 3, 1, f); - fflush(f); - fullsync(fileno(f)); - sleepmillis(2); - } - int ms = t.millis() - 2 * 500; - cout << "fullsync without growing with sleeps: " << ms << "ms, " << ms / ((double) n) << "ms/request" << endl; - } - - return 0; - } - -} // namespace mongo diff --git a/src/mongo/db/instance.h b/src/mongo/db/instance.h index 1e475f9e89d..e8ceb09d863 100644 --- a/src/mongo/db/instance.h +++ b/src/mongo/db/instance.h @@ -33,7 +33,7 @@ #include "mongo/client/dbclientinterface.h" #include "mongo/db/client.h" -#include "mongo/db/curop-inl.h" +#include "mongo/db/curop.h" #include "mongo/db/dbmessage.h" #include "mongo/db/operation_context.h" #include "mongo/db/storage_options.h" diff --git a/src/mongo/db/javatest.cpp b/src/mongo/db/javatest.cpp deleted file mode 100644 index 9171407e3b8..00000000000 --- a/src/mongo/db/javatest.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// javatest.cpp - -/** -* 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. -*/ - -#include "javajs.h" - -int main() { - JavaJS = new JavaJSImpl(); - javajstest(); -} diff --git a/src/mongo/db/minilex.h b/src/mongo/db/minilex.h deleted file mode 100644 index a3a157121be..00000000000 --- a/src/mongo/db/minilex.h +++ /dev/null @@ -1,176 +0,0 @@ -// minilex.h -// mini js lexical analyzer. idea is to be dumb and fast. - -/** -* 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. -*/ - -#error does anything use this? - -namespace mongo { - -#if defined(_WIN32) - -} // namespace mongo - -#include <hash_map> -using namespace stdext; - -namespace mongo { - - typedef const char * MyStr; - struct less_str { - bool operator()(const MyStr & x, const MyStr & y) const { - if ( strcmp(x, y) > 0) - return true; - - return false; - } - }; - - typedef hash_map<const char*, int, hash_compare<const char *, less_str> > strhashmap; - -#else - -} // namespace mongo - -#include <ext/hash_map> - -namespace mongo { - - using namespace __gnu_cxx; - - typedef const char * MyStr; - struct eq_str { - bool operator()(const MyStr & x, const MyStr & y) const { - if ( strcmp(x, y) == 0) - return true; - - return false; - } - }; - - typedef hash_map<const char*, int, hash<const char *>, eq_str > strhashmap; - -#endif - - /* - struct MiniLexNotUsed { - strhashmap reserved; - bool ic[256]; // ic=Identifier Character - bool starter[256]; - - // dm: very dumb about comments and escaped quotes -- but we are faster then at least, - // albeit returning too much (which is ok for jsbobj current usage). - void grabVariables(char *code , strhashmap& vars) { // 'code' modified and must stay in scope*/ - char *p = code; - char last = 0; - while ( *p ) { - if ( starter[*p] ) { - char *q = p+1; - while ( *q && ic[*q] ) q++; - const char *identifier = p; - bool done = *q == 0; - *q = 0; - if ( !reserved.count(identifier) ) { - // we try to be smart about 'obj' but have to be careful as obj.obj - // can happen; this is so that nFields is right for simplistic where cases - // so we can stop scanning in jsobj when we find the field of interest. - if ( strcmp(identifier,"obj")==0 && p>code && p[-1] != '.' ) - ; - else - vars[identifier] = 1; - } - if ( done ) - break; - p = q + 1; - continue; - } - - if ( *p == '\'' ) { - p++; - while ( *p && *p != '\'' ) p++; - } - else if ( *p == '"' ) { - p++; - while ( *p && *p != '"' ) p++; - } - p++; - } -} - -MiniLex() { - strhashmap atest; - atest["foo"] = 3; - verify( atest.count("bar") == 0 ); - verify( atest.count("foo") == 1 ); - verify( atest["foo"] == 3 ); - - for ( int i = 0; i < 256; i++ ) { - ic[i] = starter[i] = false; - } - for ( int i = 'a'; i <= 'z'; i++ ) - ic[i] = starter[i] = true; - for ( int i = 'A'; i <= 'Z'; i++ ) - ic[i] = starter[i] = true; - for ( int i = '0'; i <= '9'; i++ ) - ic[i] = true; - for ( int i = 128; i < 256; i++ ) - ic[i] = starter[i] = true; - ic['$'] = starter['$'] = true; - ic['_'] = starter['_'] = true; - - reserved["break"] = true; - reserved["case"] = true; - reserved["catch"] = true; - reserved["continue"] = true; - reserved["default"] = true; - reserved["delete"] = true; - reserved["do"] = true; - reserved["else"] = true; - reserved["finally"] = true; - reserved["for"] = true; - reserved["function"] = true; - reserved["if"] = true; - reserved["in"] = true; - reserved["instanceof"] = true; - reserved["new"] = true; - reserved["return"] = true; - reserved["switch"] = true; - reserved["this"] = true; - reserved["throw"] = true; - reserved["try"] = true; - reserved["typeof"] = true; - reserved["var"] = true; - reserved["void"] = true; - reserved["while"] = true; - reserved["with "] = true; -} -}; -*/ - -} // namespace mongo diff --git a/src/mongo/db/pdfile.cpp b/src/mongo/db/pdfile.cpp index bb06045ed8c..cfc7a8bf5a2 100644 --- a/src/mongo/db/pdfile.cpp +++ b/src/mongo/db/pdfile.cpp @@ -53,7 +53,7 @@ _ disallow system* manipulations from the database. #include "mongo/db/background.h" #include "mongo/db/clientcursor.h" #include "mongo/db/commands/server_status.h" -#include "mongo/db/curop-inl.h" +#include "mongo/db/curop.h" #include "mongo/db/db.h" #include "mongo/db/dbhelpers.h" #include "mongo/db/extsort.h" diff --git a/src/mongo/db/storage/mmap_v1/dur_commitjob.cpp b/src/mongo/db/storage/mmap_v1/dur_commitjob.cpp index 9ccb61e939b..8994b3f7d32 100644 --- a/src/mongo/db/storage/mmap_v1/dur_commitjob.cpp +++ b/src/mongo/db/storage/mmap_v1/dur_commitjob.cpp @@ -34,7 +34,6 @@ #include "mongo/db/client.h" #include "mongo/db/storage/mmap_v1/dur_stats.h" -#include "mongo/db/taskqueue.h" #include "mongo/util/concurrency/threadlocal.h" #include "mongo/util/stacktrace.h" diff --git a/src/mongo/db/storage/mmap_v1/dur_commitjob.h b/src/mongo/db/storage/mmap_v1/dur_commitjob.h index 5fb1a9291fa..4a1d5b66b69 100644 --- a/src/mongo/db/storage/mmap_v1/dur_commitjob.h +++ b/src/mongo/db/storage/mmap_v1/dur_commitjob.h @@ -33,7 +33,6 @@ #include "mongo/db/d_concurrency.h" #include "mongo/db/storage/mmap_v1/dur.h" #include "mongo/db/storage/mmap_v1/durop.h" -#include "mongo/db/taskqueue.h" #include "mongo/util/alignedbuilder.h" #include "mongo/util/concurrency/synchronization.h" #include "mongo/util/mongoutils/hash.h" diff --git a/src/mongo/db/taskqueue.h b/src/mongo/db/taskqueue.h deleted file mode 100644 index 31783ac007b..00000000000 --- a/src/mongo/db/taskqueue.h +++ /dev/null @@ -1,121 +0,0 @@ -// @file deferredinvoker.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 - -// if you turn this back on be sure to enable TaskQueueTest again -#if 0 - -namespace mongo { - - /** defer work items by queueing them for invocation by another thread. presumption is that - consumer thread is outside of locks more than the source thread. Additional presumption - is that several objects or micro-tasks will be queued and that having a single thread - processing them in batch is hepful as they (in the first use case) use a common data - structure that can then be in local cpu classes. - - this class is in db/ as it is dbMutex (mongomutex) specific (so far). - - using a functor instead of go() might be more elegant too, once again, would like to test any - performance differential. also worry that operator() hides things? - - MT - copyable "micro task" object we can queue - must have a static method void MT::go(const MT&) - - see DefInvoke in dbtests/ for an example. - */ - template< class MT > - class TaskQueue { - public: - TaskQueue() : _which(0), _invokeMutex("deferredinvoker") { } - - void defer(MT mt) { - // only one writer allowed. however the invoke processing below can occur concurrently with - // writes (for the most part) - DEV verify( Lock::isW() ); - - _queues[_which].push_back(mt); - } - - /** call to process deferrals. - - concurrency: handled herein. multiple threads could call invoke(), but their efforts will be - serialized. the common case is that there is a single processor calling invoke(). - - normally, you call this outside of any lock. but if you want to fully drain the queue, - call from within a read lock. for example: - { - // drain with minimal time in lock - d.invoke(); - readlock lk; - d.invoke(); - ... - } - you can also call invoke periodically to do some work and then pick up later on more. - */ - void invoke() { - mutex::scoped_lock lk2(_invokeMutex); - int toDrain = 0; - { - // flip queueing to the other queue (we are double buffered) - readlocktry lk(5); - if( !lk.got() ) - return; - toDrain = _which; - _which = _which ^ 1; - wassert( _queues[_which].empty() ); // we are in dbMutex, so it should be/stay empty til we exit dbMutex - } - - _drain( _queues[toDrain] ); - verify( _queues[toDrain].empty() ); - } - - private: - int _which; // 0 or 1 - typedef vector< MT > Queue; - Queue _queues[2]; - - // lock order when multiple locks: dbMutex, _invokeMutex - mongo::mutex _invokeMutex; - - void _drain(Queue& queue) { - unsigned oldCap = queue.capacity(); - for( typename Queue::iterator i = queue.begin(); i != queue.end(); i++ ) { - const MT& v = *i; - MT::go(v); - } - queue.clear(); - DEV verify( queue.capacity() == oldCap ); // just checking that clear() doesn't deallocate, we don't want that - } - }; - -} - -#endif diff --git a/src/mongo/db/tests.cpp b/src/mongo/db/tests.cpp deleted file mode 100644 index 65be182f4ed..00000000000 --- a/src/mongo/db/tests.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/** -* 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. -*/ - -/* tests.cpp - - unit test & such -*/ - -#include "mongo/pch.h" - -#include "mongo/util/exit.h" -#include "mongo/util/mmap.h" -#include "mongo/util/stacktrace.h" - -namespace mongo { - - int test2_old9() { - out() << "test2" << endl; - printStackTrace(); - if ( 1 ) - return 1; - - MemoryMappedFile f; - - unsigned long long len = 64*1024*1024; - char *p = (char *) f.map("/tmp/test.dat", len); - char *start = p; - char *end = p + 64*1024*1024-2; - end[1] = 'z'; - int i; - while ( p < end ) { - *p++ = ' '; - if ( ++i%64 == 0 ) { - *p++ = '\n'; - *p++ = 'x'; - } - } - *p = 'a'; - - f.flush(true); - out() << "done" << endl; - - char *x = start + 32 * 1024 * 1024; - char *y = start + 48 * 1024 * 1024; - char *z = start + 62 * 1024 * 1024; - - strcpy(z, "zfoo"); - out() << "y" << endl; - strcpy(y, "yfoo"); - strcpy(x, "xfoo"); - strcpy(start, "xfoo"); - - dbexit( EXIT_TEST ); - - return 1; - } - -} // namespace mongo |