本文整理汇总了C++中CMutex::Initialize方法的典型用法代码示例。如果您正苦于以下问题:C++ CMutex::Initialize方法的具体用法?C++ CMutex::Initialize怎么用?C++ CMutex::Initialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMutex
的用法示例。
在下文中一共展示了CMutex::Initialize方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bnbtmain
int bnbtmain( )
{
gmtxOutput.Initialize( );
srand( time( NULL ) );
giStartTime = time( NULL );
CFG_Open( CFG_FILE );
CFG_SetDefaults( );
CFG_Close( CFG_FILE );
gstrErrorLogFilePattern = CFG_GetString( "bnbt_error_log_file_pattern", "%Y-%m-%de.log" );
gstrErrorLogDir = CFG_GetString( "bnbt_error_log_dir", string( ) );
if( !gstrErrorLogDir.empty( ) && gstrErrorLogDir[gstrErrorLogDir.size( ) - 1] != PATH_SEP )
gstrErrorLogDir += PATH_SEP;
gpErrorLog = NULL;
gstrAccessLogFilePattern = CFG_GetString( "bnbt_access_log_file_pattern", "%Y-%m-%d.log" );
gstrAccessLogDir = CFG_GetString( "bnbt_access_log_dir", string( ) );
if( !gstrAccessLogDir.empty( ) && gstrAccessLogDir[gstrAccessLogDir.size( ) - 1] != PATH_SEP )
gstrAccessLogDir += PATH_SEP;
gpAccessLog = NULL;
giErrorLogCount = 0;
giAccessLogCount = 0;
giFlushInterval = CFG_GetInt( "bnbt_flush_interval", 100 );
gbDebug = CFG_GetInt( "bnbt_debug", 1 ) == 0 ? false : true;
giMaxConns = CFG_GetInt( "bnbt_max_conns", 64 );
giMaxRecvSize = CFG_GetInt( "bnbt_max_recv_size", 524288 );
gstrStyle = CFG_GetString( "bnbt_style_sheet", string( ) );
gstrCharSet = CFG_GetString( "bnbt_charset", "iso-8859-1" );
gstrRealm = CFG_GetString( "bnbt_realm", "BNBT" );
// start winsock
// TCP window size
giSO_RECBUF = CFG_GetInt( "xbnbt_so_recbuf", 128 ) * 1024;
giSO_SNDBUF = CFG_GetInt( "xbnbt_so_sndbuf", 128 ) * 1024;
#ifdef WIN32
WSADATA wsaData;
int iResult = WSAStartup( MAKEWORD(2,2), &wsaData );
if ( iResult != NO_ERROR )
{
UTIL_LogPrint( "error - unable to start winsock (error %d)\n", GetLastError( ) );
if( gpAccessLog )
fclose( gpAccessLog );
if( gpErrorLog )
fclose( gpErrorLog );
gmtxOutput.Destroy( );
return 1;
}
#endif
// start mysql
#ifdef BNBT_MYSQL
if( !( gpMySQL = mysql_init( NULL ) ) )
{
UTIL_LogPrint( "mysql error - %s\n", mysql_error( gpMySQL ) );
if( gpAccessLog )
fclose( gpAccessLog );
if( gpErrorLog )
fclose( gpErrorLog );
gmtxOutput.Destroy( );
return 1;
}
gstrMySQLHost = CFG_GetString( "mysql_host", string( ) );
gstrMySQLDatabase = CFG_GetString( "mysql_database", "bnbt" );
gstrMySQLUser = CFG_GetString( "mysql_user", string( ) );
gstrMySQLPassword = CFG_GetString( "mysql_password", string( ) );
giMySQLPort = CFG_GetInt( "mysql_port", 0 );
if( !( mysql_real_connect( gpMySQL, gstrMySQLHost.c_str( ), gstrMySQLUser.c_str( ), gstrMySQLPassword.c_str( ), gstrMySQLDatabase.c_str( ), giMySQLPort, NULL, 0 ) ) )
{
UTIL_LogPrint( "mysql error - %s\n", mysql_error( gpMySQL ) );
if( gpAccessLog )
fclose( gpAccessLog );
if( gpErrorLog )
fclose( gpErrorLog );
gmtxOutput.Destroy( );
return 1;
//.........这里部分代码省略.........
示例2: bnbtmain
int bnbtmain( )
{
gmtxOutput.Initialize( );
srand( time( NULL ) );
giStartTime = time( NULL );
CFG_Open( CFG_FILE );
CFG_SetDefaults( );
CFG_Close( CFG_FILE );
gstrErrorLogDir = CFG_GetString( "bnbt_error_log_dir", string( ) );
if( !gstrErrorLogDir.empty( ) && gstrErrorLogDir[gstrErrorLogDir.size( ) - 1] != PATH_SEP )
gstrErrorLogDir += PATH_SEP;
gpErrorLog = NULL;
gstrAccessLogDir = CFG_GetString( "bnbt_access_log_dir", string( ) );
if( !gstrAccessLogDir.empty( ) && gstrAccessLogDir[gstrAccessLogDir.size( ) - 1] != PATH_SEP )
gstrAccessLogDir += PATH_SEP;
gpAccessLog = NULL;
giErrorLogCount = 0;
giAccessLogCount = 0;
giFlushInterval = CFG_GetInt( "bnbt_flush_interval", 100 );
gbDebug = CFG_GetInt( "bnbt_debug", 1 ) == 0 ? false : true;
giMaxConns = CFG_GetInt( "bnbt_max_conns", 64 );
gstrStyle = CFG_GetString( "bnbt_style_sheet", string( ) );
gstrCharSet = CFG_GetString( "bnbt_charset", "iso-8859-1" );
gstrRealm = CFG_GetString( "bnbt_realm", "BNBT" );
// The Trinity Edition - Addition Begins
// Sets the value for the Custom NT Service Name variable
gstrNTServiceName = CFG_GetString( "trinity_nt_service_name", "BNBT Service" );
// Sets the "bnbt_alt_signup_url" value
gstrAltSignupURL = CFG_GetString( "bnbt_alt_signup_url", string( ) );
// Sets the "bnbt_tracker_title" value
gstrTrackerTitle = CFG_GetString( "bnbt_tracker_title", string( ) );
// Sets the "bnbt_external_js" value
gstrExternalJavascript = CFG_GetString( "bnbt_external_js", string( ) );
// --------------------------------------- End of Addition
// start winsock
#ifdef WIN32
WSADATA wsadata;
if( WSAStartup( MAKEWORD( 2, 0 ), &wsadata ) != 0 )
{
UTIL_LogPrint( "error - unable to start winsock (error %d)\n", GetLastError( ) );
if( gpAccessLog )
fclose( gpAccessLog );
if( gpErrorLog )
fclose( gpErrorLog );
gmtxOutput.Destroy( );
return 1;
}
#endif
gpServer = new CServer( );
gpLink = NULL;
gpLinkServer = NULL;
if( CFG_GetInt( "bnbt_tlink_server", 0 ) != 0 )
gpLinkServer = new CLinkServer( );
else
{
if( !CFG_GetString( "bnbt_tlink_connect", string( ) ).empty( ) )
{
#ifdef WIN32
if( _beginthread( ( void (*)(void *) )StartLink, 0, NULL ) == -1 )
UTIL_LogPrint( "error - unable to spawn link thread\n" );
#else
pthread_t thread;
// set detached state since we don't need to join with any threads
pthread_attr_t attr;
pthread_attr_init( &attr );
pthread_attr_setdetachstate( &attr, PTHREAD_CREATE_DETACHED );
int c = pthread_create( &thread, &attr, ( void * (*)(void *) )StartLink, NULL );
if( c != 0 )
UTIL_LogPrint( "error - unable to spawn link thread (error %s)\n", strerror( c ) );
#endif
}
}
while( 1 )
{
if( gpServer->Update( true ) )
{
delete gpServer;
//.........这里部分代码省略.........
示例3: bnbtmain
int bnbtmain( )
{
gmtxOutput.Initialize( );
gmtxMySQL.Initialize( );
UTIL_LogPrint( "Tracker Start\n" );
srand( (unsigned int)time( 0 ) );
gtStartTime = time( 0 );
CFG_Open( CFG_FILE );
CFG_SetDefaults( );
CFG_Close( CFG_FILE );
// XBNBT Language Configuration
LANG_CFG_Init( LANG_CFG_FILE );
UTIL_LogPrint( "Setting debug level, access and error log files\n" );
guiFlushInterval = CFG_GetInt( "bnbt_flush_interval", 100 );
// Log
gstrLogDir = CFG_GetString( "bnbt_log_dir", string( ) );
gstrLogFilePattern = CFG_GetString( "bnbt_log_file_pattern", "%Y-%m-%d.log" );
if( !gstrLogDir.empty( ) && gstrLogDir[gstrLogDir.size( ) - 1] != PATH_SEP )
gstrLogDir += PATH_SEP;
gpLog = 0;
gulLogCount = 0;
// Error log
gstrErrorLogDir = CFG_GetString( "bnbt_error_log_dir", string( ) );
gstrErrorLogFilePattern = CFG_GetString( "bnbt_error_log_file_pattern", "%Y-%m-%de.log" );
if( !gstrErrorLogDir.empty( ) && gstrErrorLogDir[gstrErrorLogDir.size( ) - 1] != PATH_SEP )
gstrErrorLogDir += PATH_SEP;
gpErrorLog = 0;
gulErrorLogCount = 0;
// Access log
gstrAccessLogDir = CFG_GetString( "bnbt_access_log_dir", string( ) );
gstrAccessLogFilePattern = CFG_GetString( "bnbt_access_log_file_pattern", "%Y-%m-%da.log" );
if( !gstrAccessLogDir.empty( ) && gstrAccessLogDir[gstrAccessLogDir.size( ) - 1] != PATH_SEP )
gstrAccessLogDir += PATH_SEP;
gpAccessLog = 0;
gulAccessLogCount = 0;
// Set the debug level
gbDebug = CFG_GetInt( "bnbt_debug", 1 ) == 0 ? false : true;
gucDebugLevel = (unsigned char)CFG_GetInt( "bnbt_debug_level", 0 );
UTIL_LogPrint( "***********************************************\n" );
if( gbDebug && ( gucDebugLevel & DEBUG_BNBT ) )
{
UTIL_LogPrint( "Debug is on at level (%u)\n", gucDebugLevel );
if( gstrLogDir.empty( ) )
UTIL_LogPrint( "Log directory is not set\n" );
else
UTIL_LogPrint( "Log dir (%s)\n", gstrLogDir.c_str( ) );
if( gstrErrorLogDir.empty( ) )
UTIL_LogPrint( "Error log directory is not set\n" );
else
UTIL_LogPrint( "Error log dir (%s)\n", gstrErrorLogDir.c_str( ) );
if( gstrErrorLogDir.empty( ) )
UTIL_LogPrint( "Access log directory is not set\n" );
else
UTIL_LogPrint( "Access log dir (%s)\n", gstrAccessLogDir.c_str( ) );
}
// Other globals
if( gbDebug && ( gucDebugLevel & DEBUG_BNBT ) )
UTIL_LogPrint( "Setting global variables\n" );
// PID
gstrPID = CFG_GetString( "bnbt_pid_file", string( ) );
if( gstrPID.empty( ) )
{
if( gbDebug && ( gucDebugLevel & DEBUG_BNBT ) )
UTIL_LogPrint( "PID file is not set\n" );
}
else
{
// Write the process ID to file
const long clPID( (long)getpid( ) );
UTIL_LogPrint( "Recording PID (%ld) to file (%s)\n", clPID, gstrPID.c_str( ) );
FILE *pFile = FILE_ERROR;
pFile = fopen( gstrPID.c_str( ), "wt" );
//.........这里部分代码省略.........