同步相关

#include <windows.h>
#include <mutex>
#include "SDL.h"

#define REFRESH_EVENT  (SDL_USEREVENT + 1)

static SDL_Thread* refresh_thread;
static SDL_Event event;

static int thread_exit = 0;
static int refresh_video(void* opaque) {
    while (thread_exit == 0) {
        SDL_Event event;
        event.type = REFRESH_EVENT;
        SDL_PushEvent(&event);
        SDL_Delay(4000);
    }
    return 0;
}



int main(int argc, char** argv)
{

    refresh_thread = SDL_CreateThread(refresh_video, NULL, NULL);

    while (1) {
        SDL_WaitEvent(&event);
        if (event.type == REFRESH_EVENT) {
            printf("REFRESH_EVENT \n");
        }else if (event.type == SDL_QUIT) {
            printf("SDL_QUIT \n");
            break;
        }
        printf("while\n");
    }
    return 0;
}

 

上一篇:spring核心源码分析第四篇 refresh流程之prepareBeanFactory


下一篇:uniapp原生组件_用AndroidStudio开发原生uniapp组件---uniapp一次开发_小程序_Android_IOS_快应用多端通用工作笔记005