/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Pierre Phaneuf <pp@ludusdesign.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIThread.h"
#include "nsIRunnable.h"
#include <stdio.h>
#include <stdlib.h>
#include "nspr.h"
#include "nsCOMPtr.h"
#include "nsIServiceManager.h"
public:
printf("failed to get current thread\n");
return rv;
}
// if we don't do something slow, we'll never see the other
// worker threads run
return rv;
}
}
protected:
int mNum;
};
{
printf("failed to create thread\n");
return rv;
}
printf("failed to get current thread\n");
return rv;
}
printf("runner already exited\n");
}
printf("join failed\n");
}
if (NS_SUCCEEDED(rv)) {
printf("get scope failed\n");
}
if (NS_SUCCEEDED(rv)) {
printf("interrupt failed\n");
}
////////////////////////////////////////////////////////////////////////////
// try an unjoinable thread
printf("failed to create thread\n");
return rv;
}
if (NS_SUCCEEDED(rv)) {
printf("shouldn't have been able to join an unjoinable thread\n");
}
return NS_OK;
}
public:
PR_Sleep(1);
if (!PR_AtomicDecrement(&gNum)) {
}
return NS_OK;
}
}
private:
~nsStressRunner() {
}
protected:
};
{
for (int i = 0; i < loops; i++) {
int k;
for (k = 0; k < threads; k++) {
new nsStressRunner(k),
0, PR_JOINABLE_THREAD);
}
for (k = threads-1; k >= 0; k--) {
NS_RELEASE(array[k]);
}
delete [] array;
}
return 0;
}
{
// printf(" running thread %d\n", (int) arg);
PR_Sleep(1);
}
{
for (int i = 0; i < loops; i++) {
int k;
for (k = 0; k < threads; k++) {
threadProc, (void*)(uintptr_t)k,
0);
}
for (k = 0; k < threads; k++) {
}
for (k = threads-1; k >= 0; k--) {
PR_JoinThread(array[k]);
}
delete [] array;
}
return 0;
}
int
{
int retval = 0;
int loops;
int threads;
printf("To use -stress you must pass loop count and thread count...\n"
" TestThreads -stress -1000 -50\n");
} else {
printf("Running stress test with %d loops of %d threads each\n",
}
int loops;
int threads;
printf("To use -stress-nspr you must pass loop count and thread count...\n"
" TestThreads -stress -1000 -50\n");
} else {
printf("Running stress test with %d loops of %d threads each\n",
}
} else {
rv = TestThreads();
}
return retval;
}