static void nativeVideoGetCparamCallback(const ARParam *cparam_p, void *userdata) { // Load the camera parameters, resize for the window and init. ARParam cparam; if (cparam_p) cparam = *cparam_p; else { LOGE("Unable to automatically determine camera parameters. Using default.\n"); if (arParamLoad(cparaName, 1, &cparam) < 0) { LOGE("Error: Unable to load parameter file %s for camera.\n", cparaName); return; } } if (cparam.xsize != videoWidth || cparam.ysize != videoHeight) { LOGW("*** Camera Parameter resized from %d, %d. ***\n", cparam.xsize, cparam.ysize); arParamChangeSize(&cparam, videoWidth, videoHeight, &cparam); } #ifdef DEBUG LOGD("*** Camera Parameter ***\n"); arParamDisp(&cparam); #endif if ((gCparamLT = arParamLTCreate(&cparam, AR_PARAM_LT_DEFAULT_OFFSET)) == NULL) { LOGE("Error: arParamLTCreate.\n"); return; } videoInited = true; // // AR init. // // Create the OpenGL projection from the calibrated camera parameters. arglCameraFrustumRHf(&gCparamLT->param, NEAR_PLANE, FAR_PLANE, cameraLens); cameraPoseValid = FALSE; if (!initNFT(gCparamLT, gPixFormat)) { LOGE("Error initialising NFT.\n"); arParamLTFree(&gCparamLT); return; } // Marker data has already been loaded, so now load NFT data on a second thread. nftDataLoadingThreadHandle = threadInit(0, NULL, loadNFTDataAsync); if (!nftDataLoadingThreadHandle) { LOGE("Error starting NFT loading thread.\n"); arParamLTFree(&gCparamLT); return; } threadStartSignal(nftDataLoadingThreadHandle); }
static void nativeVideoGetCparamCallback(const ARParam *cparam_p, void *userdata) { // Load the camera parameters, resize for the window and init. ARParam cparam; if (cparam_p) cparam = *cparam_p; else { arParamClearWithFOVy(&cparam, videoWidth, videoHeight, M_PI_4); // M_PI_4 radians = 45 degrees. LOGE("Using default camera parameters for %dx%d image size, 45 degrees vertical field-of-view.", videoWidth, videoHeight); } if (cparam.xsize != videoWidth || cparam.ysize != videoHeight) { #ifdef DEBUG LOGI("*** Camera Parameter resized from %d, %d. ***\n", cparam.xsize, cparam.ysize); #endif arParamChangeSize(&cparam, videoWidth, videoHeight, &cparam); } #ifdef DEBUG LOGI("*** Camera Parameter ***\n"); arParamDisp(&cparam); #endif if ((gCparamLT = arParamLTCreate(&cparam, AR_PARAM_LT_DEFAULT_OFFSET)) == NULL) { LOGE("Error: arParamLTCreate.\n"); return; } videoInited = true; // // AR init. // // Create the OpenGL projection from the calibrated camera parameters. arglCameraFrustumRHf(&gCparamLT->param, NEAR_PLANE, FAR_PLANE, cameraLens); cameraPoseValid = FALSE; if (!initNFT(gCparamLT, gPixFormat)) { LOGE("Error initialising NFT.\n"); arParamLTFree(&gCparamLT); return; } // Marker data has already been loaded, so now load NFT data on a second thread. nftDataLoadingThreadHandle = threadInit(0, NULL, loadNFTDataAsync); if (!nftDataLoadingThreadHandle) { LOGE("Error starting NFT loading thread.\n"); arParamLTFree(&gCparamLT); return; } threadStartSignal(nftDataLoadingThreadHandle); }
void inspectFile (char * fileName, uuid_t uuid) { void * threadData = NULL; if (threadInit != NULL) { if (!threadInit(&threadData)) { rzb_log(LOG_ERR, "Couldn't run nugget inspection threadInit."); exit(-1); } else { rzb_log(LOG_DEBUG, "Thread init for nugget complete."); } } sleep(sleepTime); struct EventId * eventId; eventId = calloc(1,sizeof(struct EventId)); struct Block * block = Block_Create (); struct List * list = NTLVList_Create(); struct stat st; stat(fileName, &st); //BlockPool_Init(); block->pId->iLength = st.st_size; if (!Transfer_Prepare_File(block, fileName, false)) { rzb_log(LOG_ERR, "Trouble preparing file transfer - '%s'", fileName); Block_Destroy(block); free(eventId); List_Destroy(list); return; } Hash_Update(block->pId->pHash, block->data.pointer, block->pId->iLength); Hash_Finalize(block->pId->pHash); uuid_copy(block->pId->uuidDataType,uuid); struct ContextList * current = NULL; while (contextList != NULL) { current = contextList; uint8_t ret = function (block, eventId, list, threadData); if ( ret >= 0 ) { rzb_log(LOG_NOTICE, "Returned with: %u", ret); } if (current == contextList) break; } List_Destroy(list); /*Don't need to free/destroy as it's done with the judgment. * Was needed previously because of cloning - cloning removed*/ //Block_Destroy(block); //free(eventId); if (threadCleanup != NULL) { threadCleanup(threadData); } }
int main(int argc, char *argv[]) { QApplication a(argc, argv); threadInit(); WinMainFrame *pMainWin = WinMainFrame::instance(); pMainWin->addWorkWin(new WinRoot()); pMainWin->showFullScreen(); WinTrendGroup *pTrend = new WinTrendGroup; pTrend->showFullScreen(); return a.exec(); }
THREAD_HANDLE_T *trackingInitInit( KpmHandle *kpmHandle ) { TrackingInitHandle *trackingInitHandle; THREAD_HANDLE_T *threadHandle; if (!kpmHandle) { ARLOGe("trackingInitInit(): Error: NULL KpmHandle.\n"); return (NULL); } trackingInitHandle = (TrackingInitHandle *)malloc(sizeof(TrackingInitHandle)); if( trackingInitHandle == NULL ) return NULL; trackingInitHandle->kpmHandle = kpmHandle; trackingInitHandle->imageSize = kpmHandleGetXSize(kpmHandle) * kpmHandleGetYSize(kpmHandle) * arUtilGetPixelSize(kpmHandleGetPixelFormat(kpmHandle)); trackingInitHandle->imagePtr = (ARUint8 *)malloc(trackingInitHandle->imageSize); trackingInitHandle->flag = 0; threadHandle = threadInit(0, trackingInitHandle, trackingInitMain); return threadHandle; }
void CameraSensor::threadMain() { if (cam == 0) return; threadInit(); robottime_t lastFrameTime = 0; // loop until we quit while (isRunning()) { // make sure we are still connected to a camera if (false == cam->isOpen()) { WARNING("Camera not active, trying to re-initiate"); if (false == initCamera()) { ERROR("No camera ..."); delay(250*milliseconds); continue; } } // update frame cs.enter(); bool imageCaptured = cam->capture(); cs.leave(); if (imageCaptured) { // notify any other objects that want to know about this new image for processing services.getEvents().trigger(EVT_IMAGE_CAPTURED, image); lastFrameTime = getCurrentTime(); // save image if required handleImageSaving(); } else if (lastFrameTime + 3000*milliseconds < getCurrentTime()) { ERROR("Did not receive image data for several seconds!"); // TODO: trigger watchdog in competition mode } } }
int main(void) { srand(time(NULL)); int *results[num_threads]; int p[num_threads]; int ids[num_threads]; int i; //initialize the threading library. DON'T call this more than once!!! threadInit(); set_timer(); for(i = 0; i < num_threads; i++) { //p[i] = rand()%50; p[i] = 0; ids[i] = threadCreate(t1, (void*)&(p[i])); // printf("Created thread %d.\n", ids[i]); } for(i = 0; i < num_threads; i++) { threadJoin(ids[i], (void*)&(results[i])); // printf("joined #%d --> %d.\n",ids[i], *(results[i])); } }
//------------------------------------------------------------------------------ WorkerThread::WorkerThread(ThreadSwarm &parent) : owner(parent), finalize(false), baseContext(nullptr), argumentCount(0), firstArgument(nullptr) { result res; res = semInit(&semaphore, 0); if (res == E_OK) { res = threadInit(&thread, THREAD_SIZE, THREAD_PRIORITY, workerThreadWrapper, this); } if (res != E_OK) { parent.owner.log("swarm: thread initialization error"); exit(EXIT_FAILURE); } threadOnTerminateCallback(&thread, workerTerminateWrapper, this); }
int main(int argc, char *argv[]) { int i, j; int thisSocket, thatSocket; int *confPort; unsigned int tmpSeconds; char *confConfig, *confEngine, *confPassword; char magicCookie[] = "TELLUTELLUTELLUTELLUTELLUTELLU"; size_t s; uid_t *thisUid; gid_t *thisGid; /* * * Initialize default values. * */ pMainMainInfo = &mainMainInfo; pMainThreadInfo = &mainThreadInfo; memset(pMainMainInfo, 0, sizeof(mainMainInfo)); memset(pMainThreadInfo, 0, sizeof(mainThreadInfo)); /* * * Read command line and parse configuration file. * */ cmdRead(argv, argc); if((confConfig = configFetch("config_file", &i)) != NULL) { if(configRead(confConfig) != 0) { warningMessage(ERROR_SLIGHT, "Error occurred while trying to read configuration file"); } } else { if(configRead(CONFIG_DEFAULT_FILE) != 0) { warningMessage(ERROR_SLIGHT, "Error occurred while trying to read configuration file"); } } cmdRead(argv, argc); nodeInitNames(); /* * * Initialize thread pool. * */ if((threadPool = malloc(sizeof(struct threadInfo) * THREAD_TELSKIND)) == NULL) { warningMessage(ERROR_FATAL, "Error occurred while trying to allocate memory for thread pool"); } memset(threadPool, 0, sizeof(struct threadInfo) * THREAD_TELSKIND); /* * * Initialize configurable subroutines. * */ pMainThreadInfo->threadReady = 1; for(j = 0; j < THREAD_TELSKIND; j++) { threadPool[j].threadReady = 1; threadPool[j].magicCookie = magicCookie; threadPool[j].pMainInfo = pMainMainInfo; if((confEngine = configFetch("storage_engine", &i)) != NULL) { if(strncasecmp(confEngine, "plain", strlen(confEngine)) == 0) { threadPool[j].dbInfo.connect = plainConnect; threadPool[j].dbInfo.disconnect = plainDisconnect; threadPool[j].dbInfo.escape = plainEscape; threadPool[j].dbInfo.push = plainPush; threadPool[j].dbInfo.pull = plainPull; threadPool[j].dbInfo.round = plainRound; threadPool[j].dbInfo.free = plainFree; threadPool[j].dbInfo.expire = plainExpire; threadPool[j].dbInfo.cookie = plainCookie; threadPool[j].dbInfo.insert = plainInsert; threadPool[j].dbInfo.login = plainLogin; threadPool[j].dbInfo.logout = plainLogout; threadPool[j].dbInfo.session = plainSession; threadPool[j].dbInfo.permission = plainPermission; pMainThreadInfo->dbInfo.connect = plainConnect; pMainThreadInfo->dbInfo.disconnect = plainDisconnect; pMainThreadInfo->dbInfo.escape = plainEscape; pMainThreadInfo->dbInfo.push = plainPush; pMainThreadInfo->dbInfo.pull = plainPull; pMainThreadInfo->dbInfo.round = plainRound; pMainThreadInfo->dbInfo.free = plainFree; pMainThreadInfo->dbInfo.expire = plainExpire; pMainThreadInfo->dbInfo.cookie = plainCookie; pMainThreadInfo->dbInfo.insert = plainInsert; pMainThreadInfo->dbInfo.login = plainLogin; pMainThreadInfo->dbInfo.logout = plainLogout; pMainThreadInfo->dbInfo.session = plainSession; pMainThreadInfo->dbInfo.permission = plainPermission; continue; } } threadPool[j].dbInfo.connect = mysqlConnect; threadPool[j].dbInfo.disconnect = mysqlDisconnect; threadPool[j].dbInfo.escape = mysqlEscape; threadPool[j].dbInfo.push = mysqlPush; threadPool[j].dbInfo.pull = mysqlPull; threadPool[j].dbInfo.round = mysqlRound; threadPool[j].dbInfo.free = mysqlFree; threadPool[j].dbInfo.expire = mysqlExpire; threadPool[j].dbInfo.cookie = mysqlCookie; threadPool[j].dbInfo.insert = mysqlInsert; threadPool[j].dbInfo.login = mysqlLogin; threadPool[j].dbInfo.logout = mysqlLogout; threadPool[j].dbInfo.session = mysqlSession; threadPool[j].dbInfo.permission = mysqlPermission; pMainThreadInfo->dbInfo.connect = mysqlConnect; pMainThreadInfo->dbInfo.disconnect = mysqlDisconnect; pMainThreadInfo->dbInfo.escape = mysqlEscape; pMainThreadInfo->dbInfo.push = mysqlPush; pMainThreadInfo->dbInfo.pull = mysqlPull; pMainThreadInfo->dbInfo.round = mysqlRound; pMainThreadInfo->dbInfo.free = mysqlFree; pMainThreadInfo->dbInfo.expire = mysqlExpire; pMainThreadInfo->dbInfo.cookie = mysqlCookie; pMainThreadInfo->dbInfo.insert = mysqlInsert; pMainThreadInfo->dbInfo.login = mysqlLogin; pMainThreadInfo->dbInfo.logout = mysqlLogout; pMainThreadInfo->dbInfo.session = mysqlSession; pMainThreadInfo->dbInfo.permission = mysqlPermission; } /* * * Initialize magick cookie. * */ if((confPassword = configFetch("agent_password", &i)) != NULL) { s = strlen(confPassword); if(s > DATA_COOKIE_SIZE) { s = DATA_COOKIE_SIZE; } strncpy(magicCookie, confPassword, s); } /* * * Initialize main thread. * */ configSetUmask(0077); if(configSetLocale(CONFIG_DEFAULT_LOCALE) != 0) { warningMessage(ERROR_SLIGHT, "Error occurred while trying to set default locale"); } if(configChangeRoot(CONFIG_DEFAULT_ROOT) != 0) { warningMessage(ERROR_SLIGHT, "Error occurred while trying to change root directory"); } if(configCloseInput() != 0) { warningMessage(ERROR_SLIGHT, "Error occurred while trying to close standard input"); } if(configDaemonize() != 0) { warningMessage(ERROR_SLIGHT, "Error occurred while trying to daemonize process"); } threadStack(THREAD_TELSKIND); beginProcess(pMainThreadInfo); /* * * Initialize timer. * */ if(timerInit(TIMER_RESOLUTION_STATUS, 0, timerStatThreads) != 0) { warningMessage(ERROR_FATAL, "Error occurred while trying to initialize timer"); } /* * * Initialize worker threads. * */ pMainMainInfo->allRunning = 0; pMainMainInfo->theEnd = 0; pMainMainInfo->threadEnd = 0; for(i = 0; i < THREAD_TELSKIND; i++) { if(threadInit(&threadPool[i], workerThread, &threadPool[i]) != 0) { warningMessage(ERROR_FATAL, "Error occurred while trying to initialize worker thread"); } j = 0; while(threadPool[i].threadReady != 0) { timerWait(&tmpSeconds, 0, THREAD_AGAIN); if(j == 10000 || j == 20000 || j == 30000 || j == 40000 || j == 50000) { warningMessage(ERROR_SLIGHT, "Waiting for worker threads to start taking too long, still waiting"); } else if(j >= 60000) { warningMessage(ERROR_FATAL, "Waiting for threads to start taking too long"); } j++; } } /* * * Create socket to listen. * */ if((confPort = configFetch("listen_port", &i)) != NULL) { thisSocket = netCreateListenSocket(*confPort); } else { thisSocket = netCreateListenSocket(CONFIG_DEFAULT_PORT); } /* * * Create process id, shm segment, switch user and group id's. * */ pidCreate(); shmCreate(DAEMON_TELSKIND, THREAD_TELSKIND); if((thisUid = configFetch("user_id", &i)) != NULL) { if(*thisUid != -1) { if(uidSwitch(*thisUid) != 0) { warningMessage(ERROR_SLIGHT, "Error occurred while trying to change user id"); } } } if((thisGid = configFetch("group_id", &i)) != NULL) { if(*thisGid != -1) { if(gidSwitch(*thisGid) != 0) { warningMessage(ERROR_SLIGHT, "Error occurred while trying to change group id"); } } } /* * * Serve connected clients. * */ startProcess(THREAD_TELSKIND); pMainMainInfo->allRunning++; pMainMainInfo->rushThreadCounter = 0; while(pMainMainInfo->theEnd == 0) { thatSocket = netWaitConnection(thisSocket, pMainThreadInfo); if(pMainMainInfo->theEnd != 0) { break; } mainLoop: for(i = 0; i < THREAD_TELSKIND; i++) { if(threadPool[i].threadReady == 0) { threadPool[i].threadReady++; threadPool[i].threadSocket = thatSocket; shmUpdate(i, DAEMON_TELSKIND); if(threadWake(&threadPool[i]) != 0) { netCloseSocket(threadPool[i].threadSocket); threadPool[i].threadReady = 0; threadPool[i].threadSocket = 0; warningMessage(ERROR_SLIGHT, "Error occurred while trying to start worker thread"); } pMainMainInfo->rushThreadCounter = 0; break; } } if(i == THREAD_TELSKIND) { if(pMainMainInfo->rushThreadCounter > 1000) { pMainMainInfo->rushThreadCounter = 0; warningMessage(ERROR_SLIGHT, "No free worker thread available, dropping agent"); netCloseSocket(thatSocket); } else { pMainMainInfo->rushThreadCounter++; if(pMainMainInfo->rushThreadCounter < 2) { warningMessage(ERROR_SLIGHT, "No free worker thread available, it may be necessary to enlarge the thread pool"); } timerWait(&tmpSeconds, 0, THREAD_AGAIN); goto mainLoop; } } } /* * * Free allocated resources and terminate program. * */ netCloseSocket(thisSocket); pMainMainInfo->threadEnd++; if(timerInit(TIMER_RESOLUTION_THREADSTOP, 0, timerStopThreads) == 0) { pMainMainInfo->timerThreadAccess = 1; for(i = 0; i < THREAD_TELSKIND; i++) { threadWake(&threadPool[i]); } pMainMainInfo->timerThreadAccess = 0; } else { for(i = 0; i < THREAD_TELSKIND; i++) { threadKill(&threadPool[i]); } } timesProcess(pMainThreadInfo); pidRemove(); shmRemove(DAEMON_TELSKIND); free(threadPool); exitProcess(0); exit(0); }
int main(int argc, char *argv[]) { char *ampersand; App *app; unsigned char *equals; HTTPNameValue *h; HTTPNameValue *headers; char *name; unsigned char *newURL; char *p; char *query; unsigned char *referer; URL *u; unsigned char *url; char *verbose; char *version; View *view; if (!netInit()) { return 1; } if (!threadInit()) { return 1; } referer = NULL; url = NULL; verbose = "?url="; query = getenv("QUERY_STRING"); app = appAlloc(); app->html = cgiviewHTML; app->htmlAttributeName = cgiviewHTMLAttributeName; app->htmlAttributeValue = cgiviewHTMLAttributeValue; app->htmlDeclaration = cgiviewHTMLDeclaration; app->htmlProcessingInstruction = cgiviewHTMLProcessingInstruction; app->htmlTag = cgiviewHTMLTag; app->htmlText = cgiviewHTMLText; app->httpRequest = cgiviewHTTPRequest; app->httpRequestHeaderName = cgiviewHTTPRequestHeaderName; app->httpRequestHeaderValue = cgiviewHTTPRequestHeaderValue; app->httpResponse = cgiviewHTTPResponse; app->httpResponseBody = cgiviewHTTPResponseBody; app->httpResponseHeaderName = cgiviewHTTPResponseHeaderName; app->httpResponseHeaderValue = cgiviewHTTPResponseHeaderValue; app->printHTML = cgiviewPrintHTML; view = &app->view; view->out = stdout; freopen("/dev/null", "w", stderr); fprintf(view->out, "Content-Type: text/html\n"); fprintf(view->out, "\n"); if (query) { p = query; do { name = p; ampersand = strchr(p, '&'); if (ampersand) { *ampersand = 0; p = ampersand + 1; } equals = (unsigned char *) strchr(name, '='); if (equals) { *equals = 0; if (!strcmp(name, "referer")) { referer = equals + 1; urlDecode(referer); } else if (!strcmp(name, "url")) { url = equals + 1; urlDecode(url); } else if (!strcmp(name, "verbose")) { verbose = "?verbose=on&url="; viewVerbose(); } } } while (ampersand); } else if (argc > 1) { url = (unsigned char *) argv[1]; } else { fprintf(view->out, "no environment variable QUERY_STRING<br>\n"); fprintf(view->out, "and no arg passed<br>\n"); return 1; } if (url && (*url)) { fprintf(view->out, "<html><head><title>View %s</title>", url); fprintf(view->out, "<link rel=stylesheet href=view.css>"); fprintf(view->out, "</head><body>\n"); viewReport(app, "input url:"); viewReport(app, (char *) url); viewReportHTML(app, "<hr>"); u = urlParse(url); if ( ((!u->scheme)||(!strcmp((char *) u->scheme, "http"))) && (!u->host) && (*url != '/') ) { newURL = calloc(strlen((char *) url) + 3, 1); if (!newURL) { viewReport(app, "calloc failed"); return 1; } strcpy((char *) newURL, "//"); strcat((char *) newURL, (char *) url); } else { newURL = copyString(url); } urlFree(u); u = urlParse(newURL); if ( ( (!u->scheme) || (!strcmp((char *) u->scheme, "http")) ) && (!*u->path) ) { url = newURL; newURL = calloc(strlen((char *) url) + 2, 1); if (!newURL) { viewReport(app, "calloc failed"); return 1; } strcpy((char *) newURL, (char *) url); free(url); strcat((char *) newURL, "/"); } urlFree(u); u = urlRelative( (unsigned char *) "http://www.mozilla.org/index.html", newURL); free(newURL); viewReport(app, "fully qualified url:"); viewReport(app, (char *) u->url); viewReportHTML(app, "<hr>"); if (!strcmp((char *) u->scheme, "http")) { version = NULL; headers = cgiviewGetEnv(app, (char *) referer, verbose, &version); if (!headers) { return 1; } httpFree(httpProcess(app, u, version, headers)); h = headers; while (h->name) { free(h->name); free(h->value); h++; } free(headers); } else { fprintf ( view->out, "Sorry, %s URLs are not supported yet. " "Only http URLs are supported.", u->scheme ); } fprintf(view->out, "</body></html>\n"); } else { fprintf(view->out, "<html><head><title>SniffURI Error</title>"); fprintf(view->out, "</head><body><h2>Please enter a URI</h2>"); fprintf(view->out, "<a href=index.html>Go Back</a>"); fprintf(view->out, "</body></html>"); } exit(0); return 1; }
int surfSubGetDescriptors( SurfSubIPointArrayT *iPointArray, int *image, int width, int height, int border, int maxNum, int threadNum ) { #if 1 int k = 0; for(int i = 0; i < iPointArray->num; i++) { int x, y, s; x = (int)(iPointArray->iPoint[i].x+0.5); y = (int)(iPointArray->iPoint[i].y+0.5); s = (int)(iPointArray->iPoint[i].scale+0.5); if( x-s*20 < 0 || y-s*20 < 0 || x+s*20 >= width || y+s*20 >= height ) { continue; } if( i != k ) { iPointArray->iPoint[k] = iPointArray->iPoint[i]; } k++; } iPointArray->num = k; if( iPointArray->num == 0 ) return 0; #endif if( maxNum > 0 ) { if( iPointArray->num > maxNum ) { qsort( iPointArray->iPoint, iPointArray->num, sizeof(SurfSubIPointT), compSurfP ); iPointArray->num = maxNum; } } static int initF = 0; static int threadMax; static THREAD_HANDLE_T **threadHandle; static SurfSubGetDescriptorsParam *arg; if( initF == 0 ) { threadMax = threadGetCPU(); threadHandle = (THREAD_HANDLE_T **)malloc(sizeof(THREAD_HANDLE_T*)*threadMax); if( threadHandle == NULL ) {ARLOGe("Malloc error: surfSubGetDescriptors.\n"); exit(0);} arg = (SurfSubGetDescriptorsParam *)malloc(sizeof(SurfSubGetDescriptorsParam)*threadMax); if( arg == NULL ) {ARLOGe("Malloc error: surfSubGetDescriptors.\n"); exit(0);} for(int i = 0; i < threadMax; i++ ) { threadHandle[i] = threadInit(i, &(arg[i]), surfSubGetDescriptorsSub); } initF = 1; } if( threadNum < 0 ) threadNum = threadMax; if( threadNum > threadMax ) threadNum = threadMax; char *flag = (char *)malloc(iPointArray->num); int i = iPointArray->num/threadNum; int j = iPointArray->num%threadNum; k = 0; for(int l = 0; l < j; l++ ) { arg[l].iPoint = iPointArray->iPoint; arg[l].flag = flag; arg[l].image = image; arg[l].width = width; arg[l].height = height; arg[l].border = border; arg[l].startNum = k; arg[l].endNum = k + i; threadStartSignal( threadHandle[l] ); k += (i+1); } for(int l = j; l < threadNum; l++ ) { arg[l].iPoint = iPointArray->iPoint; arg[l].flag = flag; arg[l].image = image; arg[l].width = width; arg[l].height = height; arg[l].border = border; arg[l].startNum = k; arg[l].endNum = k + i - 1; threadStartSignal( threadHandle[l] ); k += i; } for(int l = 0; l < threadNum; l++ ) { threadEndWait( threadHandle[l] ); } k = 0; for(int i = 0; i < iPointArray->num; i++) { if( flag[i] == 0 ) continue; if( i != k ) { iPointArray->iPoint[k] = iPointArray->iPoint[i]; } k++; } iPointArray->num = k; free(flag); /* for(int i = 0; i < iPointArray->num; i++) { if( getOrientation(&(iPointArray->iPoint[i]), image, width, height, border) < 0 ) { for( int j = i+1; j < iPointArray->num; j++ ) iPointArray->iPoint[j-1] = iPointArray->iPoint[j]; iPointArray->num--; i--; continue; } if( getDescriptor(&(iPointArray->iPoint[i]), image, width, height, border) < 0 ) { for( int j = i+1; j < iPointArray->num; j++ ) iPointArray->iPoint[j-1] = iPointArray->iPoint[j]; iPointArray->num--; i--; continue; } } */ return 0; }
detachedThread_t * detachedThreadInit(const void * ptrFunction, void * ptrParameters) { assert(ptrFunction); return threadInit(ptrFunction, ptrParameters, THREAD_DEFAULT_STACK_SIZE, 0); }