// native socket_create_t() static cell AMX_NATIVE_CALL socket_create_t(AMX *amx, cell *params) /* no param */ { THREAD th; CThreadedSocketItem *SocketThread = new CThreadedSocketItem; #ifdef _WIN32 th = THREAD_create(ThreadMain, SocketThread); if( th == NULL ) { delete SocketThread; return -1; } #else int rc = THREAD_create(&th, ThreadMain, SocketThread); if( rc ) { delete SocketThread; return -1; } #endif // Attach thread to SocketThread SocketThread->Thread(th); // Add current thread object to list g_ThreadedSocketManager->AddItemToList(SocketThread); // return casted SocketThread return ((cell)(SocketThread)); }
void templateAppInit( int width, int height ) { atexit( templateAppExit ); GFX_start(); AUDIO_start(); thread = THREAD_create( decompress_stream, NULL, THREAD_PRIORITY_NORMAL, 1 ); glViewport( 0.0f, 0.0f, width, height ); glGetIntegerv( GL_VIEWPORT, viewport_matrix ); srandom( get_milli_time() ); load_level(); }
float run_test(const char *buf) { thread_arg_t t_arg[NUM_THREADS]; thread_t t[NUM_THREADS]; for(int i = 0; i < NUM_THREADS; i++) { t_arg[i].index = i; t_arg[i].buf = buf; THREAD_create(&t[i], worker_thread, &t_arg[i]); } float e2_tot = 0.0f; int num_pos = 0; for(int i = 0; i < NUM_THREADS; i++) { THREAD_join(t[i]); e2_tot += t_arg[i].error; num_pos += t_arg[i].num_positions; } float mse = sqrtf(e2_tot/num_pos); return mse; }
int JASTS_SEARCH_proc_start() { ThreadId_t tid; THREAD_create(tid,JASTS_SEARCH_proc,NULL); return 0; }