当前位置: 首页>>代码示例>>C++>>正文


C++ SDL_WaitThread函数代码示例

本文整理汇总了C++中SDL_WaitThread函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_WaitThread函数的具体用法?C++ SDL_WaitThread怎么用?C++ SDL_WaitThread使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了SDL_WaitThread函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SDL_mutexP

void FrameExporter::stop() {
    if(!thread) return;
    
    if(dumper_thread_state == FRAME_EXPORTER_STOPPED || dumper_thread_state == FRAME_EXPORTER_EXIT) return;

    SDL_mutexP(mutex);

        dumper_thread_state = FRAME_EXPORTER_EXIT;

        SDL_CondSignal(cond);

    SDL_mutexV(mutex);

    SDL_WaitThread(thread, 0);
    
    thread = 0;
}
开发者ID:mukteshkrmishra,项目名称:Core,代码行数:17,代码来源:ppm.cpp

示例2: ijkmp_destroy

inline static void ijkmp_destroy(IjkMediaPlayer *mp)
{
    if (!mp)
        return;

    ffp_destroy_p(&mp->ffplayer);
    if (mp->msg_thread) {
        SDL_WaitThread(mp->msg_thread, NULL);
        mp->msg_thread = NULL;
    }

    pthread_mutex_destroy(&mp->mutex);

    freep((void**)&mp->data_source);
    memset(mp, 0, sizeof(IjkMediaPlayer));
    freep((void**)&mp);
}
开发者ID:17media,项目名称:ijkplayer,代码行数:17,代码来源:ijkplayer.c

示例3: l_thread_newThread

static int l_thread_newThread(lua_State* state) {
    thread_Data* data = (thread_Data*) lua_newuserdata(state, sizeof(thread_Data));
    moduleData.state = state;

    const char* name = luaL_optstring(state, 2, NULL);
    data->thread = SDL_CreateThread((SDL_ThreadFunction)callback, name, (void *)NULL);

    if (NULL == data->thread) 
        luaL_error(state, "\n Create thread failed: %s\n", SDL_GetError());
    else 
        SDL_WaitThread(data->thread, &data->res);
    
    lua_rawgeti(state, LUA_REGISTRYINDEX, moduleData.threadDataMT);
    lua_setmetatable(state, -2);

    return 1;
}
开发者ID:dns,项目名称:CLove,代码行数:17,代码来源:thread.c

示例4: SDL_WaitThread

AutoPilotWindow::~AutoPilotWindow() {
	//destroy parser thread
	parser_wait=0;
	if(parser_thread)
		SDL_WaitThread(parser_thread,NULL);
	parser_thread=NULL;
    if(tasker)
    	delete tasker;
	if(parser)
		delete parser;
	if(port)
		delete port;
	if(logs)
	   delete logs;
	if(input)
		delete input;
}
开发者ID:hamzakilic,项目名称:autopilot_manager,代码行数:17,代码来源:AutoPilotWindow.cpp

示例5: main

int main(int argc, char **argv) {
    if (argc < 2 || argc > 2) {
        printf("Usage:  %s  image.flif\n",argv[0]);
        return 0;
    }
    d = flif_create_decoder();
    if (!d) return 1;

    SDL_Init(SDL_INIT_VIDEO);
    window = SDL_CreateWindow("FLIF Viewer", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 200, 200, 0);
    flif_decoder_set_quality(d, 100);   // this is the default
    flif_decoder_set_scale(d, 1);       // this is the default
#ifdef PROGRESSIVE_DECODING
    flif_decoder_set_callback(d, &(progressive_render));
    flif_decoder_set_first_callback_quality(d, 500);   // do the first callback when at least 5.00% quality has been decoded
    printf("Decoding progressively...\n");
    SDL_Thread *decode_thread = SDL_CreateThread(decodeThread,"Decode_FLIF",argv);
    if (!decode_thread) {
        printf("Error: failed to create decode thread\n");
        return 1;
    }
#else
    printf("Decoding entire image...\n");
    decodeThread(argv);
    progressive_render(10000,-1);
#endif
    SDL_Event e;
    int result = 0;
    while (!quit) {
        draw_image();
        if (animation) {
            SDL_Delay(frame_delay[frame]);
            frame++;
            frame %= flif_decoder_num_images(d);
        } else { SDL_WaitEvent(&e); if (!do_event(e)) break; SDL_Delay(100); }
        while (SDL_PollEvent(&e)) if (!do_event(e)) break;
    }
#ifdef PROGRESSIVE_DECODING
    while(flif_abort_decoder(d)) SDL_Delay(100);
    SDL_WaitThread(decode_thread, &result);
#endif
    flif_destroy_decoder(d);
    SDL_DestroyWindow(window);
    SDL_Quit();
    return result;
}
开发者ID:mkadunc,项目名称:FLIF,代码行数:46,代码来源:viewflif.c

示例6: Thread_Shutdown_

/**
 * Thread_Shutdown_
 */
static void Thread_Shutdown_(void) {

	if (thread_pool.num_threads) {
		thread_t *t = thread_pool.threads;
		uint16_t i = 0;

		for (i = 0; i < thread_pool.num_threads; i++, t++) {
			Thread_Wait(t);
			SDL_CondSignal(t->cond);
			SDL_WaitThread(t->thread, NULL);
			SDL_DestroyCond(t->cond);
			SDL_DestroyMutex(t->mutex);
		}

		Mem_Free(thread_pool.threads);
	}
}
开发者ID:jayschwa,项目名称:quake2world,代码行数:20,代码来源:thread.c

示例7: SDL_CreateThread

int AVIWrapper::play(bool click_flag)
{
    int ret = 0;
    time_start = 0;
    status = AVI_PLAYING;
    if (v_stream)
        thread_id = SDL_CreateThread(::playVideo, this);

    if (a_stream)
        Mix_HookMusic(::audioCallback, this);

    bool done_flag = false;
    while (!(done_flag & click_flag) && status == AVI_PLAYING) {
        SDL_Event event;

        while (SDL_PollEvent(&event)) {
            switch (event.type) {
            case SDL_KEYDOWN:
                if (((SDL_KeyboardEvent*) &event)->keysym.sym == SDLK_RETURN
                    || ((SDL_KeyboardEvent*) &event)->keysym.sym == SDLK_KP_ENTER
                    || ((SDL_KeyboardEvent*) &event)->keysym.sym == SDLK_SPACE
                    || ((SDL_KeyboardEvent*) &event)->keysym.sym == SDLK_ESCAPE)
                    done_flag = true;

                break;
            case SDL_QUIT:
                ret = 1;
            case SDL_MOUSEBUTTONDOWN:
                done_flag = true;
                break;
            default:
                break;
            }
        }
        SDL_Delay(10);
    }

    status = AVI_STOP;
    if (v_stream)
        SDL_WaitThread(thread_id, NULL);

    if (a_stream)
        Mix_HookMusic(NULL, NULL);

    return ret;
}
开发者ID:Animus120,项目名称:ponscripter-fork,代码行数:46,代码来源:AVIWrapper.cpp

示例8: main

int main(int argc, char **argv)
{
	SDL_Thread *threads[NUM_THREADS];
	uintptr_t i;
	int init_sem;

	if(argc < 2) {
		fprintf(stderr,"Usage: %s init_value\n", argv[0]);
		return(1);
	}

	/* Load the SDL library */
	if ( SDL_Init(0) < 0 ) {
		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
		return(1);
	}
	signal(SIGTERM, killed);
	signal(SIGINT, killed);
	
	init_sem = atoi(argv[1]);
	sem = SDL_CreateSemaphore(init_sem);
	
	printf("Running %d threads, semaphore value = %d\n", NUM_THREADS, init_sem);
#if 0 
	/* Create all the threads */
	for( i = 0; i < NUM_THREADS; ++i ) {
		threads[i] = SDL_CreateThread(ThreadFunc, (void*)i);
	}

	/* Wait 10 seconds */
	SDL_Delay(10 * 1000);

	/* Wait for all threads to finish */
	printf("Waiting for threads to finish\n");
	alive = 0;
	for( i = 0; i < NUM_THREADS; ++i ) {
		SDL_WaitThread(threads[i], NULL);
	}

	printf("Finished waiting for threads\n");
#endif
	SDL_DestroySemaphore(sem);
	SDL_Quit();
	return(0);
}
开发者ID:cuttl,项目名称:wii2600,代码行数:45,代码来源:testsem.c

示例9: main

int main(){

	mainData = malloc(sizeof(struct main_ProgramData));
		//initialze the webcam
	mainData->LocalWebcamData = VIDEO_webcamload("/dev/video0");
	//So we can know to print debug shit
	mainData->verbose = 1;
	//Right now we don't want the render thread to do anything until we SemPost this
	mainData->UI_renderhold = SDL_CreateSemaphore(0);
	//This is the thread that sets up the video surface and handles events
	mainData->UI_initandeventthread = SDL_CreateThread(UI_Initialize, NULL);
	//Thread where the rendering happens
	mainData->UI_renderthread = SDL_CreateThread( UI_thread, NULL);
	
	SDL_WaitThread(mainData->UI_initandeventthread, NULL);
	return 0;

}
开发者ID:TrevorDorl,项目名称:noidea-chat,代码行数:18,代码来源:main.c

示例10: tilt_free

void tilt_free(void)
{
    if (mutex)
    {
        /* Get/set the status of the tilt sensor thread. */

        SDL_mutexP(mutex);
        state.status = 0;
        SDL_mutexV(mutex);

        /* Wait for the thread to terminate and destroy the mutex. */

        SDL_WaitThread(thread, NULL);
        SDL_DestroyMutex(mutex);
        mutex  = NULL;
        thread = NULL;
    }
}
开发者ID:Neverball,项目名称:neverball,代码行数:18,代码来源:tilt_wii.c

示例11: locker

	Thread::~Thread() {
		SDL_Thread *th = NULL;
		{
			AutoLocker locker(&lock);
			th = (SDL_Thread *)threadInfo;
			if(!th)
				return;
		}
		
		// we have to ensure thread handle is destroyed.
		if(SDL_ThreadID() == threadId) {
			// thread is deleting itself.
			// SDL_WaitThread would cause deadlock.
			cleanuper->Add(th);
		}else{
			SDL_WaitThread(th, NULL);
		}
	}
开发者ID:2mac,项目名称:openspades,代码行数:18,代码来源:Thread.cpp

示例12: SDL_WaitThread

void Graphics::DeinitGraphics()
{
	if (Graphics::Handle)
		Graphics::ThreadData.flag = 0;
		SDL_WaitThread(Graphics::ThreadData.thread, NULL);
		for (int i = 0; Graphics::dlObjectList[i]; i++ )
		{
			free(Graphics::dlObjectList[i]);
			Graphics::dlObjectList[i] = NULL;
		}
		for (int i = 0; Graphics::dlSpriteList[i]; i++ )
		{
			free(Graphics::dlSpriteList[i]);
			Graphics::dlSpriteList[i] = NULL;
		}
		delete Graphics::Handle;
		SDL_Quit();
}
开发者ID:n0name,项目名称:2D_Engine,代码行数:18,代码来源:graphics.cpp

示例13: SDL_WaitThread

WhoIsOnline::~WhoIsOnline()
{
    config.removeListeners(this);

    if (mThread && SDL_GetThreadID(mThread))
        SDL_WaitThread(mThread, nullptr);

    free(mMemoryBuffer);
    mMemoryBuffer = nullptr;

    // Remove possibly leftover temporary download
    delete []mCurlError;

    FOR_EACH (std::set<OnlinePlayer*>::iterator, itd, mOnlinePlayers)
        delete *itd;
    mOnlinePlayers.clear();
    mOnlineNicks.clear();
}
开发者ID:koo5,项目名称:manaplus,代码行数:18,代码来源:whoisonline.cpp

示例14: n2s_destruct

static EEL_xno n2s_destruct(EEL_object *eo)
{
	EB_socket *ebs = o2EB_socket(eo);
	if(!ebs->rs)
		return 0;	/* Detached! We're done here. */
	if(ebs->rs->sender)
	{
		ebs->rs->closed = 1;
		SDL_WaitThread(ebs->rs->sender, NULL);
		sfifo_close(&ebs->rs->fifo);
	}
	NET2_TCPClose(ebs->rs->n2socket);
	if(ebs->rs->n2socket >= 0)
		if(eb_sockets)
			eb_sockets[ebs->rs->n2socket] = NULL;
	free(ebs->rs);
	return 0;
}
开发者ID:coppolaemilio,项目名称:eel,代码行数:18,代码来源:eb_net.c

示例15: SDL_SemPost

void NetworkManager::cleanUp()
{
    network_running = false;

    SDL_SemPost(semaphore);
    int st;
    SDL_WaitThread(resolverThread, &st);

    SDL_DestroySemaphore(semaphore);
    semaphore = 0;
    resolverThread = 0;

    rqueue.clear();

#ifdef _WIN32
    WSACleanup();
#endif
}
开发者ID:LucasVini,项目名称:OldNetPanzer,代码行数:18,代码来源:NetworkManager.cpp


注:本文中的SDL_WaitThread函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。