*not part of the buld*
blackConnect tests update git-svn-id: svn://10.0.0.236/trunk@99925 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
#include "plstr.h"
|
||||
#include "prmem.h"
|
||||
#include "stdio.h"
|
||||
#include "nsIComponentManager.h"
|
||||
#include "MThreadComponent2.h"
|
||||
@@ -31,10 +32,25 @@
|
||||
#include <stdlib.h>
|
||||
#include "nsID.h"
|
||||
|
||||
iMThreadContext* context;
|
||||
void* iThread;
|
||||
void* eThread;
|
||||
|
||||
iMThreadContext* context=NULL;
|
||||
iMThreadComponent* tComponent=NULL;
|
||||
void* iThread=NULL;
|
||||
void* eThread=NULL;
|
||||
int newT=0, newS=0;
|
||||
|
||||
void Exec(void* arg) {
|
||||
tComponent->Initialize(context);
|
||||
nsIComponentManager* cm;
|
||||
nsresult rv = NS_GetGlobalComponentManager(&cm);
|
||||
if(NS_FAILED(rv)) {
|
||||
fprintf(stderr, "ERROR: Can't get GlobalComponentManager!!\n");
|
||||
return;
|
||||
}
|
||||
tComponent->THack(cm);
|
||||
tComponent->Execute(newT,newS);
|
||||
}
|
||||
|
||||
MThreadComponent2Impl::MThreadComponent2Impl()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
@@ -54,37 +70,77 @@ NS_IMETHODIMP MThreadComponent2Impl::Initialize(iMThreadContext* c){
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP MThreadComponent2Impl::Execute(const char* tName){
|
||||
printf("MThreadComponent2Impl::Execute. Thread is %s\n", tName);
|
||||
eThread = PR_GetCurrentThread();
|
||||
if(eThread == iThread) {
|
||||
printf("###Execute and initialize were executed in one thread\n");
|
||||
}else {
|
||||
printf("###Execute and initialize were executed in DIFFERENT threads\n");
|
||||
}
|
||||
char* progID;
|
||||
context->GetNext(&progID);
|
||||
nsCID classID;
|
||||
classID.Parse(progID);
|
||||
printf("MThreadComponent2Impl::Execute. progID is %s\n",progID);
|
||||
iMThreadComponent* tComponent;
|
||||
nsresult rv = nsComponentManager::CreateInstance(classID,
|
||||
nsnull,
|
||||
NS_GET_IID(iMThreadComponent),
|
||||
(void**)&tComponent);
|
||||
if(NS_FAILED(rv)) {
|
||||
printf("MThreadComponent2Impl:Create instance failed from %s!!!",classID.ToString());
|
||||
return rv;
|
||||
}
|
||||
tComponent->Initialize(context);
|
||||
tComponent->Execute(tName);
|
||||
|
||||
NS_IMETHODIMP MThreadComponent2Impl::THack(nsIComponentManager* cm){
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP MThreadComponent2Impl::Execute(int thread, int stage){
|
||||
|
||||
char* tmp=(char*)PR_Malloc(sizeof(char*));
|
||||
tmp="";
|
||||
FILE *file;
|
||||
|
||||
printf("MThreadComponent2Impl::Execute.\n");
|
||||
eThread = PR_GetCurrentThread();
|
||||
if(eThread == iThread) {
|
||||
printf("###Execute and initialize were executed in one thread\n");
|
||||
} else {
|
||||
printf("###Execute and initialize were executed in DIFFERENT threads\n");
|
||||
}
|
||||
|
||||
char* progID;
|
||||
char* res=(char*)PR_Malloc(sizeof(char*));
|
||||
|
||||
context->GetResFile(&res);
|
||||
|
||||
if ((file = fopen(res, "a+t")) == NULL) {
|
||||
fprintf(stderr, "ERROR: can't open file %s\n",res);
|
||||
return NS_OK;
|
||||
}
|
||||
sprintf(tmp,"%d,%d,",thread,stage);
|
||||
fwrite(tmp,1,strlen(tmp),file);
|
||||
sprintf(tmp,"%d\n",eThread);
|
||||
fwrite(tmp,1,strlen(tmp),file);
|
||||
fclose(file);
|
||||
|
||||
context->GetContractID(thread,stage+1,&progID);
|
||||
nsCID classID;
|
||||
|
||||
classID.Parse(progID);
|
||||
nsresult rv = nsComponentManager::CreateInstance(classID,
|
||||
nsnull,
|
||||
NS_GET_IID(iMThreadComponent),
|
||||
(void**)&tComponent);
|
||||
if(NS_FAILED(rv)) {
|
||||
fprintf(stderr, "MThreadComponent2Impl:Create instance failed from %s!!!\n",classID.ToString());
|
||||
} else {
|
||||
tComponent->Initialize(context);
|
||||
nsIComponentManager* cm;
|
||||
rv = NS_GetGlobalComponentManager(&cm);
|
||||
if(NS_FAILED(rv)) {
|
||||
fprintf(stderr, "ERROR: Can't get GlobalComponentManager!!\n");
|
||||
return NS_OK;
|
||||
}
|
||||
tComponent->THack(cm);
|
||||
tComponent->Execute(thread,stage+1);
|
||||
}
|
||||
|
||||
|
||||
context->GetContractID(thread+1,stage+1,&progID);
|
||||
classID.Parse(progID);
|
||||
rv = nsComponentManager::CreateInstance(classID, nsnull,
|
||||
NS_GET_IID(iMThreadComponent),
|
||||
(void**)&tComponent);
|
||||
if(NS_FAILED(rv)) {
|
||||
fprintf(stderr, "MThreadComponent2Impl: 2: Create instance failed from %s!!!\n",progID);
|
||||
} else {
|
||||
newT=thread+1;
|
||||
newS=stage+1;
|
||||
PR_CreateThread(PR_USER_THREAD, Exec,
|
||||
this, PR_PRIORITY_NORMAL, PR_LOCAL_THREAD,
|
||||
PR_UNJOINABLE_THREAD, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user