コード例 #1
0
ファイル: ipcd.c プロジェクト: nawhizz/KAIT
/*
void
CheckArguments(int argc, char *argv[])
{
	if (argc>1)
	{
		if (argv[1][0] == 'D')
		{
			StopIPCD();
			ExitProcess(1);
		}
		else if (argv[1][0] != 'S')
		{
			printf("Usage : ipcd S ; Start IPCD\n");
			printf("        ipcd D ; Stop  IPCD\n");
			ExitProcess(1);
		}

		hMutex=CreateMutex(NULL, FALSE, "IPCDMUTEX");
		if (hMutex==NULL)
		{
			sprintf(tbuf, "Create Mutex error = [%d]", GetLastError());
			MessageBox(NULL, tbuf, "IPC DAEMON", MB_OK);
			ExitProcess(1);
		}
		else
		{
			if (GetLastError()==ERROR_ALREADY_EXISTS)
			{
				MessageBox(NULL, "IPC DAEMON is already active ...", 
				"IPC DAEMON", MB_OK);
				CloseHandle(hMutex);
				ExitProcess(1);
			}
		}
		return;
	}
	printf("Usage : ipcd S ; Start IPCD\n");
	printf("        ipcd D ; Stop  IPCD\n");
	ExitProcess(1);
}
*/
void
CheckArguments(char *argv)
{
	if (argv[0] == 'D' || argv[0] == 'd')
	{
		StopIPCD();
		ExitProcess(1);
	}
	else if (argv[0] != 'S' && argv[0] != 's')
	{
		sprintf(tbuf, "Usage : ipcd s ; Start IPCD\n        ipcd d ; Stop  IPCD\n");
		MessageBox(NULL, tbuf, "IPC DAEMON", MB_OK);
		ExitProcess(1);
	}

	hShmIpcMutex = MakeMutex(SHMIPCMUTEX);
	hSemIpcMutex = MakeMutex(SEMIPCMUTEX);
	hShmPinfoMutex = MakeMutex(SHMPINFOMUTEX);
	hSemPinfoMutex = MakeMutex(SEMPINFOMUTEX);
	return;
}
コード例 #2
0
ファイル: RageThreads.cpp プロジェクト: Prcuvu/StepMania-3.95
RageMutex::RageMutex( const CString name ):
	m_sName( name )
{
	m_pMutex = MakeMutex( this );
	m_LockedBy = GetInvalidThreadId();
	m_LockCnt = 0;


/*	if( g_FreeMutexIDs == NULL )
	{
		g_FreeMutexIDs = new set<int>;
		for( int i = 0; i < MAX_MUTEXES; ++i )
			g_FreeMutexIDs->insert( i );
	}

	if( g_FreeMutexIDs->empty() )
	{
		ASSERT_M( g_MutexList, "!g_FreeMutexIDs but !g_MutexList?" ); // doesn't make sense to be out of mutexes yet never created any
		CString s;
		for( unsigned i = 0; i < g_MutexList->size(); ++i )
		{
			if( i )
				s += ", ";
			s += ssprintf( "\"%s\"", (*g_MutexList)[i]->GetName().c_str() );
		}
		LOG->Trace( "%s", s.c_str() );
		FAIL_M( ssprintf("MAX_MUTEXES exceeded creating \"%s\"", name.c_str() ) );
	}

	m_UniqueID = *g_FreeMutexIDs->begin();

	g_FreeMutexIDs->erase( g_FreeMutexIDs->begin() );

	if( g_MutexList == NULL )
		g_MutexList = new vector<RageMutex*>;

	g_MutexList->push_back( this );
*/
}