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


C++ SDL_DestroyMutex函数代码示例

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


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

示例1: init_threads

/* Initialize SDL threading */
void init_threads(void)
{
    struct thread_entry *thread;
    int n;

    memset(cores, 0, sizeof(cores));
    memset(threads, 0, sizeof(threads));

    m = SDL_CreateMutex();

    if (SDL_LockMutex(m) == -1)
    {
        fprintf(stderr, "Couldn't lock mutex\n");
        return;
    }

    /* Initialize all IDs */
    for (n = 0; n < MAXTHREADS; n++)
        threads[n].id = THREAD_ID_INIT(n);

    /* Slot 0 is reserved for the main thread - initialize it here and
       then create the SDL thread - it is possible to have a quick, early
       shutdown try to access the structure. */
    thread = &threads[0];
    thread->stack = (uintptr_t *)"       ";
    thread->stack_size = 8;
    thread->name = "main";
    thread->state = STATE_RUNNING;
    thread->context.s = SDL_CreateSemaphore(0);
    thread->context.t = NULL; /* NULL for the implicit main thread */
    cores[CURRENT_CORE].running = thread;

    if (thread->context.s == NULL)
    {
        fprintf(stderr, "Failed to create main semaphore\n");
        return;
    }

    /* Tell all threads jump back to their start routines, unlock and exit
       gracefully - we'll check each one in turn for it's status. Threads
       _could_ terminate via remove_thread or multiple threads could exit
       on each unlock but that is safe. */

    /* Setup jump for exit */
    if (setjmp(thread_jmpbufs[0]) == 0)
    {
        THREAD_SDL_DEBUGF("Main thread: %p\n", thread);
        return;
    }

    SDL_UnlockMutex(m);

    /* Set to 'COMMAND_DONE' when other rockbox threads have exited. */
    while (threads_status < THREADS_EXIT_COMMAND_DONE)
        SDL_Delay(10);

    SDL_DestroyMutex(m);

    /* We're the main thead - perform exit - doesn't return. */
    sim_do_exit();
}
开发者ID:ntj,项目名称:rockbox,代码行数:62,代码来源:thread-sdl.c

示例2: SDL_DestroyMutex

BXEntitlementsManager::~BXEntitlementsManager()
{
  SDL_DestroyMutex(m_entitlementsListGuard);
  
}
开发者ID:flyingtime,项目名称:boxee,代码行数:5,代码来源:bxentitlementsmanager.cpp

示例3: SDL_DestroyMutex

void EventKeyboard::destroyMutex() {

    SDL_DestroyMutex(mutexKeyData);

}
开发者ID:gcielniak,项目名称:TrackDrone,代码行数:5,代码来源:EventKeyboard.cpp

示例4: SDL_DestroyMutex

mutex::~mutex()
{
	SDL_DestroyMutex(m_);
}
开发者ID:ArtBears,项目名称:wesnoth,代码行数:4,代码来源:thread.cpp

示例5: SDL_DestroyMutex

PlayerBucket::~PlayerBucket() {
  SDL_DestroyMutex(lock);
}
开发者ID:pgoodman,项目名称:ece1747,代码行数:3,代码来源:PlayerBucket.cpp

示例6: SDL_DestroyMutex

template <typename T> scm_queue<T>::~scm_queue()
{
    SDL_DestroyMutex    (data_mutex);
    SDL_DestroySemaphore(free_slots);
    SDL_DestroySemaphore(full_slots);
}
开发者ID:rlk,项目名称:scm,代码行数:6,代码来源:scm-queue.hpp

示例7: RunFIFOTest

static void RunFIFOTest(SDL_bool lock_free)
{
    SDL_EventQueue queue;
    WriterData writerData[NUM_WRITERS];
    ReaderData readerData[NUM_READERS];
    Uint32 start, end;
    int i, j;
    int grand_total;
 
    printf("\nFIFO test---------------------------------------\n\n");
    printf("Mode: %s\n", lock_free ? "LockFree" : "Mutex");

    readersDone = SDL_CreateSemaphore(0);
    writersDone = SDL_CreateSemaphore(0);

    SDL_memset(&queue, 0xff, sizeof(queue));

    InitEventQueue(&queue);
    if (!lock_free) {
        queue.mutex = SDL_CreateMutex();
    }

    start = SDL_GetTicks();
 
#ifdef TEST_SPINLOCK_FIFO
    /* Start a monitoring thread */
    if (lock_free) {
        SDL_CreateThread(FIFO_Watcher, "FIFOWatcher", &queue);
    }
#endif

    /* Start the readers first */
    printf("Starting %d readers\n", NUM_READERS);
    SDL_zero(readerData);
    SDL_AtomicSet(&readersRunning, NUM_READERS);
    for (i = 0; i < NUM_READERS; ++i) {
        char name[64];
        SDL_snprintf(name, sizeof (name), "FIFOReader%d", i);
        readerData[i].queue = &queue;
        readerData[i].lock_free = lock_free;
        SDL_CreateThread(FIFO_Reader, name, &readerData[i]);
    }

    /* Start up the writers */
    printf("Starting %d writers\n", NUM_WRITERS);
    SDL_zero(writerData);
    SDL_AtomicSet(&writersRunning, NUM_WRITERS);
    for (i = 0; i < NUM_WRITERS; ++i) {
        char name[64];
        SDL_snprintf(name, sizeof (name), "FIFOWriter%d", i);
        writerData[i].queue = &queue;
        writerData[i].index = i;
        writerData[i].lock_free = lock_free;
        SDL_CreateThread(FIFO_Writer, name, &writerData[i]);
    }
 
    /* Wait for the writers */
    while (SDL_AtomicGet(&writersRunning) > 0) {
        SDL_SemWait(writersDone);
    }
 
    /* Shut down the queue so readers exit */
    queue.active = SDL_FALSE;

    /* Wait for the readers */
    while (SDL_AtomicGet(&readersRunning) > 0) {
        SDL_SemWait(readersDone);
    }

    end = SDL_GetTicks();
 
    SDL_DestroySemaphore(readersDone);
    SDL_DestroySemaphore(writersDone);

    if (!lock_free) {
        SDL_DestroyMutex(queue.mutex);
    }
 
    printf("Finished in %f sec\n", (end - start) / 1000.f);

    printf("\n");
    for (i = 0; i < NUM_WRITERS; ++i) {
        printf("Writer %d wrote %d events, had %d waits\n", i, EVENTS_PER_WRITER, writerData[i].waits);
    }
    printf("Writers wrote %d total events\n", NUM_WRITERS*EVENTS_PER_WRITER);

    /* Print a breakdown of which readers read messages from which writer */
    printf("\n");
    grand_total = 0;
    for (i = 0; i < NUM_READERS; ++i) {
        int total = 0;
        for (j = 0; j < NUM_WRITERS; ++j) {
            total += readerData[i].counters[j];
        }
        grand_total += total;
        printf("Reader %d read %d events, had %d waits\n", i, total, readerData[i].waits);
        printf("  { ");
        for (j = 0; j < NUM_WRITERS; ++j) {
            if (j > 0) {
                printf(", ");
//.........这里部分代码省略.........
开发者ID:D-Quick,项目名称:DQuick,代码行数:101,代码来源:testatomic.c

示例8: SDL_DestroyMutex

Server::~Server(){
	SDL_DestroyMutex(mxClients);
	SDL_DestroyMutex(mxGoSerial);
	delete myIdServer;
}
开发者ID:beepted,项目名称:ac_online_server,代码行数:5,代码来源:Server.cpp

示例9: SDL_DestroyMutex

draw_maint_map::~draw_maint_map()
{
	themap = 0;
	SDL_DestroyMutex(draw_mtx);
	draw_mtx = 0;
}
开发者ID:tea91,项目名称:l1j-client,代码行数:6,代码来源:draw_maint_map.cpp

示例10: SDL_DestroyMutex

Mutex::~Mutex()
{
	SDL_DestroyMutex(mutex);
}
开发者ID:ascetic85,项目名称:love2d,代码行数:4,代码来源:threads.cpp

示例11: Host_InitCommon


//.........这里部分代码省略.........

#ifdef __ANDROID__
	if (chdir(host.rootdir) == 0)
		MsgDev(D_INFO,"%s is working directory now",host.rootdir);
	else
		MsgDev(D_ERROR,"%s is not exists",host.rootdir);
#else
	// we can specified custom name, from Sys_NewInstance
	if( SDL_GetBasePath() && !host.change_game )
	{
		Q_strncpy( szTemp, SDL_GetBasePath(), sizeof(szTemp) );
		FS_FileBase( szTemp, SI.ModuleName );
	}

	if(moduleName) Q_strncpy(SI.ModuleName, moduleName, sizeof(SI.ModuleName));

	FS_ExtractFilePath( SI.ModuleName, szRootPath );
	if( Q_stricmp( host.rootdir, szRootPath ))
	{
		Q_strncpy( host.rootdir, szRootPath, sizeof( host.rootdir ));
#ifdef _WIN32
		SetCurrentDirectory( host.rootdir );
#else
		chdir( host.rootdir );
#endif
	}
#endif

	if( SI.ModuleName[0] == '#' ) host.type = HOST_DEDICATED; 

	// determine host type
	if( progname[0] == '#' )
	{
		Q_strncpy( SI.ModuleName, progname + 1, sizeof( SI.ModuleName ));
		host.type = HOST_DEDICATED;
	}
	else Q_strncpy( SI.ModuleName, progname, sizeof( SI.ModuleName )); 

	if( host.type == HOST_DEDICATED )
	{
		// check for duplicate dedicated server
		host.hMutex = SDL_CreateMutex(  );

		if( !host.hMutex )
		{
			MSGBOX( "Dedicated server already running" );
			Sys_Quit();
			return;
		}

		Sys_MergeCommandLine( cmdLine );

		SDL_DestroyMutex( host.hMutex );
		host.hMutex = SDL_CreateSemaphore( 0 );
		if( host.developer < 3 ) host.developer = 3; // otherwise we see empty console
	}
	else
	{
		// don't show console as default
		if( host.developer < D_WARN ) host.con_showalways = false;
	}

	host.old_developer = host.developer;

	Con_CreateConsole();

	// first text message into console or log 
	MsgDev( D_NOTE, "Sys_LoadLibrary: Loading xash.dll - ok\n" );

	// startup cmds and cvars subsystem
	Cmd_Init();
	Cvar_Init();

	// share developer level across all dlls
	Q_snprintf( dev_level, sizeof( dev_level ), "%i", host.developer );
	Cvar_Get( "developer", dev_level, CVAR_INIT, "current developer level" );
	Cmd_AddCommand( "exec", Host_Exec_f, "execute a script file" );
	Cmd_AddCommand( "memlist", Host_MemStats_f, "prints memory pool information" );

	FS_Init();
	Image_Init();
	Sound_Init();

	FS_LoadGameInfo( NULL );
	Q_strncpy( host.gamefolder, GI->gamefolder, sizeof( host.gamefolder ));


	if( GI->secure )
	{
		// clear all developer levels when game is protected
		Cvar_FullSet( "developer", "0", CVAR_INIT );
		host.developer = host.old_developer = 0;
		host.con_showalways = false;
	}

	HPAK_Init();

	IN_Init();
	Key_Init();
}
开发者ID:emileb,项目名称:xash3d,代码行数:101,代码来源:host.c

示例12: del

	static void del(SDL_mutex *m) { SDL_DestroyMutex(m); }
开发者ID:CUE0,项目名称:gambatte,代码行数:1,代码来源:audiosink.cpp

示例13: SDL_DestroyCond

THAVPacketQueue::~THAVPacketQueue()
{
    SDL_DestroyCond(m_pCond);
    SDL_DestroyMutex(m_pMutex);
}
开发者ID:raurodse,项目名称:CorsixTH,代码行数:5,代码来源:th_movie.cpp

示例14: audio_close

void audio_close(void)
{
    SDL_DestroyMutex(g_audio_mutex);
    SDL_PauseAudio(true);
    SDL_CloseAudio();
}
开发者ID:bkz,项目名称:libspotify-sdl,代码行数:6,代码来源:jukebox.cpp

示例15: abs_thread_mutex_destroy

int abs_thread_mutex_destroy(abs_thread_mutex_t *mutex) {
  SDL_DestroyMutex(*mutex);
  return true;
}
开发者ID:serghei,项目名称:kde3-kdemultimedia,代码行数:4,代码来源:abs_thread_sdl.cpp


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