コード例 #1
0
ファイル: network.c プロジェクト: gregtour/netBEAM
int ShutdownNetwork(NET_STATE* ref)
{
  if (!ref->threadTerminated) {
    void* ret_value;
    LWP_JoinThread(ref->thread_handle, &ret_value);
  }

  net_close(ref->socket);
  return 0;
}
コード例 #2
0
void ExitGUIThreads()
{
    ExitRequested = true;

    if(guithread != LWP_THREAD_NULL)
    {
        ResumeGui();
        LWP_JoinThread(guithread, NULL);
        guithread = LWP_THREAD_NULL;
    }
}
コード例 #3
0
SoundHandler::~SoundHandler()
{
	ExitRequested = true;
	ThreadSignal();
	LWP_JoinThread(SoundThread, NULL);
	SoundThread = LWP_THREAD_NULL;
	if(ThreadStack)
		free(ThreadStack);

	ClearDecoderList();
}
コード例 #4
0
ファイル: networkop.cpp プロジェクト: ifish12/WiiTweet
/****************************************************************************
 * StopNetworkThread
 *
 * Signals the network thread to stop
 ***************************************************************************/
void StopNetworkThread()
{
	if(networkthread == LWP_THREAD_NULL || !LWP_ThreadIsSuspended(networkthread))
		return;

	netHalt = 2;
	LWP_ResumeThread(networkthread);

	// wait for thread to finish
	LWP_JoinThread(networkthread, NULL);
	networkthread = LWP_THREAD_NULL;
}
コード例 #5
0
ファイル: wiiload.c プロジェクト: fagensden/postloader-1
void WiiLoad_Stop(void)
	{
	int tout;
	
	Debug ("WiiLoad_Stop");
	if (!started || stopNetworkThread == 1)
		{
		Debug ("WiiLoad_Stop: nothing to do...");
		return; // 
		}
		
	stopNetworkThread = 1;	
	stopGeckoThread = 1;
	
	tout = 0;
	while ((stopNetworkThread == 1 || stopGeckoThread == 1) && tout < 50)
		{
		usleep (100000);
		tout++;
		}
		
	if (tout < 50)
		{
		LWP_JoinThread (networkthread, NULL);
		LWP_JoinThread (geckothread, NULL);
		free (threadStack);
		free (threadStackG);

		// Clean old data, if any
		if (wiiload.args) free (wiiload.args);
		}
	else	
		Debug ("WiiLoad_Stop: Something gone wrong ! %d %d", stopNetworkThread, stopGeckoThread );

	
	wiiload.args = NULL;
	wiiload.argl = 0;

	Debug ("WiiLoad_Stop: done...");
	}
コード例 #6
0
ファイル: gui.c プロジェクト: AveryEvans/d2x-cios-installer
void destroyBlinkTexts(struct stBlinkTextsGroup *stBlinkTexts) {
unsigned char i;
    if (stBlinkTexts->intThreadId!=LWP_THREAD_NULL) {
        while (LWP_MutexLock(stBlinkTexts->mtxThread)) {}
        for (i=0;i<stBlinkTexts->chBlinkTextsCount;i++) {
            stBlinkTexts->stBlinkTexts[i].stBlinkTimer.blnRunning=false;
            free(stBlinkTexts->stBlinkTexts[i].strBlinkText);
            stBlinkTexts->stBlinkTexts[i].strBlinkText=NULL;
        }
        LWP_MutexUnlock(stBlinkTexts->mtxThread);
        LWP_JoinThread(stBlinkTexts->intThreadId,NULL);
        LWP_MutexDestroy(stBlinkTexts->mtxThread);
        stBlinkTexts->intThreadId=LWP_THREAD_NULL;
        stBlinkTexts->mtxThread=LWP_MUTEX_NULL;
    }
}
コード例 #7
0
ファイル: audio.c プロジェクト: DusterTheThief2/mupen64gc
EXPORT void CALL
RomClosed( void )
{
#ifdef THREADED_AUDIO
	// Destroy semaphores and suspend the thread so audio can't play
	if(!thread_running) LWP_SemPost(first_audio);
	thread_running = 0;
	LWP_SemDestroy(buffer_full);
	LWP_SemDestroy(buffer_empty);
	LWP_SemDestroy(audio_free);
	LWP_SemDestroy(first_audio);
	LWP_JoinThread(audio_thread, NULL);
	audio_paused = 0;
#endif
	AUDIO_StopDMA(); // So we don't have a buzzing sound when we exit the game
}
コード例 #8
0
ファイル: osystem_sfx.cpp プロジェクト: 0xf1sh/scummvm
void OSystem_Wii::deinitSfx() {
	if (_mixer)
		_mixer->setReady(false);

	AUDIO_StopDMA();
	AUDIO_RegisterDMACallback(NULL);

	if (sfx_thread_running) {
		sfx_thread_quit = true;
		LWP_ThreadBroadcast(sfx_queue);

		LWP_JoinThread(sfx_thread, NULL);
		LWP_CloseQueue(sfx_queue);

		free(sfx_stack);
		sfx_thread_running = false;

		for (u32 i = 0; i < SFX_BUFFERS; ++i)
			free(sound_buffer[i]);
	}
}
コード例 #9
0
ファイル: threads.c プロジェクト: DCurrent/openbor
void thread_join(bor_thread *thread)
{
	void *status;
	LWP_JoinThread(thread->thread, &status);
	free(thread);
}
コード例 #10
0
void SDL_SYS_WaitThread(SDL_Thread *thread)
{
    void *v;
    LWP_JoinThread(thread->handle, &v);
    return;
}
コード例 #11
0
ファイル: drawgx.c プロジェクト: Vandepad/sdl-mame-wii
static void drawgx_window_destroy(sdl_window_info *window)
{
    thread_window = NULL;
    LWP_JoinThread(vidthread, NULL);
    vidthread = LWP_THREAD_NULL;
}
コード例 #12
0
void CMenu::_system()
{
	int msg = 0, newVer = SVN_REV_NUM;
	lwp_t thread = LWP_THREAD_NULL;
	wstringEx prevMsg;

	int amount_of_skips = 0;
	int update_x = 0, update_y = 0;
	u32 update_w = 0, update_h = 0;
	bool first = true;

	m_btnMgr.reset(m_systemLblInfo, true);

	SetupInput();
	m_btnMgr.setText(m_systemBtnBack, _t("dl1", L"Cancel"));
	m_thrdStop = false;
	m_thrdMessageAdded = false;
	m_showtimer = -1;
	while(!m_exit)
	{
		_mainLoopCommon();
		if(amount_of_skips == 0) // Check dimensions in the loop, because the animation can have an effect
			m_btnMgr.getDimensions(m_systemLblInfo, update_x, update_y, update_w, update_h); // Get original dimensions
		if(first)
		{
			m_btnMgr.moveBy(m_systemLblInfo, 0, -(pixels_to_skip * 10));
			amount_of_skips++;
			first = false;
		}

		if (m_showtimer == -1)
		{
			m_showtimer = 120;
			m_btnMgr.show(m_downloadPBar);
			m_btnMgr.setProgress(m_downloadPBar, 0.f);
			m_thrdStop = false;
			m_thrdWorking = true;
			LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_versionTxtDownloaderInit, 
								(void *)this, downloadStack, downloadStackSize, 40);
		}
		if (m_showtimer > 0 && !m_thrdWorking)
		{
			if (thread != LWP_THREAD_NULL)
			{
				LWP_JoinThread(thread, NULL);
				thread = LWP_THREAD_NULL;
			}
			if (--m_showtimer == 0)
			{
				m_btnMgr.hide(m_downloadPBar);
				m_btnMgr.hide(m_downloadLblMessage[0], 0, 0, -2.f, 0.f);
				m_btnMgr.hide(m_downloadLblMessage[1], 0, 0, -2.f, 0.f);
				CMenu::_version[1] = m_version.getInt("GENERAL", "version", SVN_REV_NUM);
				num_versions = m_version.getInt("GENERAL", "num_versions", 1);
				for (i = 2; i < num_versions; i++)
				{
					CMenu::_version[i] = m_version.getInt(fmt("VERSION%i", i-1u), "version", SVN_REV_NUM);
					//add the changelog info here
				}
				if (num_versions > 1 && version_num == 0) version_num = 1;
				i = min((u32)version_num, ARRAY_SIZE(CMenu::_version) -1u);
				newVer = CMenu::_version[i];
				_showSystem();
			}
		}
		if ((BTN_DOWN_PRESSED || BTN_DOWN_HELD) && !(m_thrdWorking && m_thrdStop))
		{
			if (update_h - (amount_of_skips * pixels_to_skip) > (m_vid.height2D() - (35 + update_y)))
			{
				m_btnMgr.moveBy(m_systemLblInfo, 0, -pixels_to_skip);
				amount_of_skips++;
			}
		}
		else if ((BTN_UP_PRESSED || BTN_UP_HELD) && !(m_thrdWorking && m_thrdStop))
		{
			if (amount_of_skips > 1)
			{
				m_btnMgr.moveBy(m_systemLblInfo, 0, pixels_to_skip);
				amount_of_skips--;
			}
		}
		else if ((BTN_HOME_PRESSED || BTN_B_PRESSED || m_exit) && !m_thrdWorking)
			break;
		else if ((BTN_A_PRESSED) && !(m_thrdWorking && m_thrdStop))
		{
			if ((m_btnMgr.selected(m_systemBtnDownload)) && !m_thrdWorking)
			{
				// Download selected version
				_hideSystem();
				m_btnMgr.show(m_downloadPBar);
				m_btnMgr.setProgress(m_downloadPBar, 0.f);
				m_thrdStop = false;
				m_thrdWorking = true;
				gprintf("\nVersion to DL: %i\n", newVer);

				if(m_version.getInt("GENERAL", "version", 0) == newVer)
					m_app_update_size = m_version.getInt("GENERAL", "app_zip_size", 0);
				m_data_update_size = m_version.getInt("GENERAL", "data_zip_size", 0);

				m_app_update_url = fmt("%s/Wiiflow_Mod_svn_r%i.zip", m_version.getString("GENERAL", "update_url", "http://open-wiiflow-mod.googlecode.com/files").c_str(), newVer);
				m_data_update_url = fmt("%s/r%i/data.zip", m_version.getString("GENERAL", "update_url", "http://open-wiiflow-mod.googlecode.com/files").c_str(), newVer);

				m_showtimer = 120;
				LWP_CreateThread(&thread, (void *(*)(void *))CMenu::_versionDownloaderInit, 
									(void *)this, downloadStack, downloadStackSize, 40);
				if (m_exit && !m_thrdWorking) 
				{
					m_thrdStop = true;
					break;
				}
			}
			else if (m_btnMgr.selected(m_systemBtnBack))
			{
				LockMutex lock(m_mutex);
				m_thrdStop = true;
				m_thrdMessageAdded = true;
				m_thrdMessage = _t("dlmsg6", L"Canceling...");
			}
			else if (m_btnMgr.selected(m_systemBtnVerSelectM))
			{
				if (version_num > 1)
					--version_num;
				else
					version_num = num_versions;
				i = min((u32)version_num, ARRAY_SIZE(CMenu::_version) -1u);
				{
					m_btnMgr.setText(m_systemLblVerSelectVal, wstringEx(sfmt("%i", CMenu::_version[i])));
					newVer = CMenu::_version[i];
					m_app_update_size = m_version.getInt(sfmt("VERSION%i", i - 1u), "app_zip_size", 0);
					if (i > 1 && i != num_versions)
						m_btnMgr.setText(m_systemLblInfo, m_version.getWString(sfmt("VERSION%i", i - 1u), "changes"), false);
					else 
						if (i == num_versions)
							m_btnMgr.setText(m_systemLblInfo, _t("sys7", L"Installed Version."), false);
						else
							m_btnMgr.setText(m_systemLblInfo, m_version.getWString("GENERAL", "changes"), false);
				}
			}
			else if (m_btnMgr.selected(m_systemBtnVerSelectP))
			{
				if (version_num < num_versions)
					++version_num;
				else
					version_num = 1;
				i = min((u32)version_num, ARRAY_SIZE(CMenu::_version) -1u);
				{
					m_btnMgr.setText(m_systemLblVerSelectVal, wstringEx(sfmt("%i", CMenu::_version[i])));
					newVer = CMenu::_version[i];
					m_app_update_size = m_version.getInt(sfmt("VERSION%i", i - 1u), "app_zip_size", 0);
					if (i > 1 && i != num_versions)
						m_btnMgr.setText(m_systemLblInfo, m_version.getWString(sfmt("VERSION%i", i - 1u), "changes"), false);
					else 
						if (i == num_versions)
							m_btnMgr.setText(m_systemLblInfo, _t("sys7", L"Installed Version."), false);
						else
							m_btnMgr.setText(m_systemLblInfo, m_version.getWString("GENERAL", "changes"), false);
				}
			}
		}
		if (Sys_Exiting())
		{
			LockMutex lock(m_mutex);
			m_thrdStop = true;
			m_thrdMessageAdded = true;
			m_thrdMessage = _t("dlmsg6", L"Canceling...");
		}
		// 
		if (m_thrdMessageAdded)
		{
			LockMutex lock(m_mutex);
			m_thrdMessageAdded = false;
			m_btnMgr.setProgress(m_downloadPBar, m_thrdProgress);
			if (m_thrdProgress == 1.f)
				m_btnMgr.setText(m_systemBtnBack, _t("dl2", L"Back"));
			if (prevMsg != m_thrdMessage)
			{
				prevMsg = m_thrdMessage;
				m_btnMgr.setText(m_downloadLblMessage[msg], m_thrdMessage, false);
				m_btnMgr.hide(m_downloadLblMessage[msg], -200, 0, 1.f, 0.5f, true);
				m_btnMgr.show(m_downloadLblMessage[msg]);
				msg ^= 1;
				m_btnMgr.hide(m_downloadLblMessage[msg], +400, 0, 1.f, 1.f);
			}
		}
		if (m_thrdStop && !m_thrdWorking)
			break;
	}
	if (thread != LWP_THREAD_NULL)
	{
		LWP_JoinThread(thread, NULL);
		thread = LWP_THREAD_NULL;
	}
	_hideSystem();
}
コード例 #13
0
/****************************************************************************
 * ShutdownThread
 ***************************************************************************/
void ShutdownNetworkThread()
{
	LWP_JoinThread(networkthread, NULL);
	networkthread = LWP_THREAD_NULL;
}
コード例 #14
0
ThreadedTask::~ThreadedTask()
{
	ExitRequested = true;
	Execute();
	LWP_JoinThread(Thread, NULL);
}