• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ CheckConnection函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: UpdateClients

void StepManiaLanServer::UpdateClients()
{
	//Go through all the clients and check to see if it is being used.
	//If so then try to get a backet and parse the data.
	for (unsigned int x = 0; x < Client.size(); ++x)
		if (CheckConnection(x) && (Client[x]->GetData(Packet) >= 0))
			ParseData(Packet, x);
}
开发者ID:augustg,项目名称:stepmania-3.9,代码行数:8,代码来源:NetworkSyncServer.cpp


示例2: SetValGTM

/*
 * Set values for sequence
 */
int
SetValGTM(char *seqname, GTM_Sequence nextval, bool iscalled)
{
	GTM_SequenceKeyData seqkey;
	CheckConnection();
	seqkey.gsk_keylen = strlen(seqname) + 1;
	seqkey.gsk_key = seqname;

	return conn ? set_val(conn, &seqkey, nextval, iscalled) : -1;
}
开发者ID:kisehiroshi,项目名称:postgres-xc,代码行数:13,代码来源:gtm.c


示例3: AlterSequenceGTM

/*
 * Alter a sequence on the GTM
 */
int
AlterSequenceGTM(char *seqname, GTM_Sequence increment, GTM_Sequence minval,
				 GTM_Sequence maxval, GTM_Sequence startval, GTM_Sequence lastval, bool cycle, bool is_restart)
{
	GTM_SequenceKeyData seqkey;
	CheckConnection();
	seqkey.gsk_keylen = strlen(seqname) + 1;
	seqkey.gsk_key = seqname;

	return conn ? alter_sequence(conn, &seqkey, increment, minval, maxval, startval, lastval, cycle, is_restart) : 0;
}
开发者ID:kisehiroshi,项目名称:postgres-xc,代码行数:14,代码来源:gtm.c


示例4: CheckPower

void JohanCity::UpdateTime(float dt) {

	clock->Start();
	
	// Optimized version of power checking...
	CheckPower(); // crawls from power plant outward...
	
	// Optimized version of water checking...
	CheckWater(); // crawls from water source outward...
	
	// TODO: optimize?
	CheckConnection();

	checktilems = clock->Reset() * 1000.0f;
	
	// Then apply tile info to buildings
	CheckBuildingRequisites();
	
	checkbuildingms = clock->Reset() * 1000.0f;

	// Done checking for required items? Spend the RCI
	for(int i = 0;i < tiles.size();i++) {
		for(int j = 0;j < tiles[i].size();j++) {
			TileType type = tiles[i][j]->type;
			if(type == ttResidential || type == ttCommercial || type == ttIndustrial) {
				tiles[i][j]->UpdateTime(dt);
			}
			
			// Undo checks (so they won't get invalid)?
			tiles[i][j]->checkid = -1;
//			tiles[i][j]->powered = false;
//			tiles[i][j]->watered = false;
//			tiles[i][j]->connected = false;
		}
	}
	
	updatetilems = clock->Reset() * 1000.0f;
	
	for(std::list<Building*>::iterator i = buildings.begin();i != buildings.end();i++) {
		Building* building = *i;
		building->UpdateTime(dt);
	}
	
	updatebuildingms = clock->Reset() * 1000.0f;
	
	snprintf(timingreport,256,
		"Check tile time: %.2f ms\r\nCheck building time: %.2f ms\r\nUpdate tile time: %.2f ms\r\nUpdate building time: %.2f ms\r\n",
		checktilems,
		checkbuildingms,
		updatetilems,
		updatebuildingms);
	
	UpdateBuffers();
}
开发者ID:JohanMes,项目名称:JohanCity,代码行数:54,代码来源:JohanCity.cpp


示例5: DropSequenceGTM

/*
 * Drop the sequence depending the key type
 *
 * Type of Sequence name use in key;
 *		GTM_SEQ_FULL_NAME, full name of sequence
 *		GTM_SEQ_DB_NAME, DB name part of sequence key
 */
int
DropSequenceGTM(char *name, GTM_SequenceKeyType type)
{
	GTM_SequenceKeyData seqkey;
	CheckConnection();
	seqkey.gsk_keylen = strlen(name) + 1;
	seqkey.gsk_key = name;
	seqkey.gsk_type = type;

	return conn ? close_sequence(conn, &seqkey) : -1;
}
开发者ID:kisehiroshi,项目名称:postgres-xc,代码行数:18,代码来源:gtm.c


示例6: CreateSequenceGTM

/*
 * Create a sequence on the GTM.
 */
int
CreateSequenceGTM(char *seqname, GTM_Sequence increment, GTM_Sequence minval,
				  GTM_Sequence maxval, GTM_Sequence startval, bool cycle)
{
	GTM_SequenceKeyData seqkey;
	CheckConnection();
	seqkey.gsk_keylen = strlen(seqname) + 1;
	seqkey.gsk_key = seqname;

	return conn ? open_sequence(conn, &seqkey, increment, minval, maxval, startval, cycle) : 0;
}
开发者ID:kisehiroshi,项目名称:postgres-xc,代码行数:14,代码来源:gtm.c


示例7: RenameSequenceGTM

/*
 * Rename the sequence
 */
int
RenameSequenceGTM(char *seqname, const char *newseqname)
{
	GTM_SequenceKeyData seqkey, newseqkey;
	CheckConnection();
	seqkey.gsk_keylen = strlen(seqname) + 1;
	seqkey.gsk_key = seqname;
	newseqkey.gsk_keylen = strlen(newseqname) + 1;
	newseqkey.gsk_key = (char *) newseqname;

	return conn ? rename_sequence(conn, &seqkey, &newseqkey) : -1;
}
开发者ID:kisehiroshi,项目名称:postgres-xc,代码行数:15,代码来源:gtm.c


示例8: ReportBarrierGTM

/*
 * Report BARRIER
 */
int
ReportBarrierGTM(char *barrier_id)
{
	if (!gtm_backup_barrier)
		return;

	CheckConnection();

	if (!conn)
		return EOF;

	return(report_barrier(conn, barrier_id));
}
开发者ID:HunterChen,项目名称:postgres-xc,代码行数:16,代码来源:gtm.c


示例9: GetSnapshotGTM

GTM_Snapshot
GetSnapshotGTM(GlobalTransactionId gxid, bool canbe_grouped)
{
	GTM_Snapshot ret_snapshot = NULL;
	CheckConnection();
	if (conn)
		ret_snapshot = get_snapshot(conn, gxid, canbe_grouped);
	if (ret_snapshot == NULL)
	{
		CloseGTM();
		InitGTM();
	}
	return ret_snapshot;
}
开发者ID:kisehiroshi,项目名称:postgres-xc,代码行数:14,代码来源:gtm.c


示例10: while

void NetworkThread::Run()
{
	while(ReceiveMessages())
	{
		if(myPacket && !myPacket.endOfPacket())
		{
			ParseMessages();
			myPacket.clear();
		}
		
		CheckConnection();
		
		sf::sleep(sf::milliseconds(100));
	}
}
开发者ID:boomshanka,项目名称:Papouja,代码行数:15,代码来源:NetworkThread.cpp


示例11: GetNextValGTM

GetNextValGTM(char *seqname)
#endif
{
	GTM_Sequence ret = -1;
	GTM_SequenceKeyData seqkey;
#ifdef XCP
	char   *coordName = IS_PGXC_COORDINATOR ? PGXCNodeName : MyCoordName;
	int		coordPid = IS_PGXC_COORDINATOR ? MyProcPid : MyCoordPid;
	int		status;
#endif
	CheckConnection();
	seqkey.gsk_keylen = strlen(seqname) + 1;
	seqkey.gsk_key = seqname;

#ifdef XCP
	if (conn)
		status = get_next(conn, &seqkey, coordName,
						  coordPid, range, &ret, rangemax);
	else
		status = GTM_RESULT_COMM_ERROR;

	/* retry once */
	if (status == GTM_RESULT_COMM_ERROR)
	{
		CloseGTM();
		InitGTM();
		if (conn)
			status = get_next(conn, &seqkey, coordName, coordPid,
							  range, &ret, rangemax);
	}
	if (status != GTM_RESULT_OK)
		ereport(ERROR,
				(errcode(ERRCODE_INTERNAL_ERROR),
				 errmsg("%s", GTMPQerrorMessage(conn))));
#else
	if (conn)
		ret = get_next(conn, &seqkey);
	if (ret < 0)
	{
		CloseGTM();
		InitGTM();
	}
#endif
	return ret;
}
开发者ID:techdragon,项目名称:Postgres-XL,代码行数:45,代码来源:gtm.c


示例12: AcceptResult

/*
 * AcceptResult
 *
 * Checks whether a result is valid, giving an error message if necessary;
 * and ensures that the connection to the backend is still up.
 *
 * Returns true for valid result, false for error state.
 */
static bool
AcceptResult(const PGresult *result)
{
	bool		OK;

	if (!result)
		OK = false;
	else
		switch (PQresultStatus(result))
		{
			case PGRES_COMMAND_OK:
			case PGRES_TUPLES_OK:
			case PGRES_EMPTY_QUERY:
			case PGRES_COPY_IN:
			case PGRES_COPY_OUT:
			case PGRES_COPY_BOTH:
				/* Fine, do nothing */
				OK = true;
				break;

			case PGRES_BAD_RESPONSE:
			case PGRES_NONFATAL_ERROR:
			case PGRES_FATAL_ERROR:
				OK = false;
				break;

			default:
				OK = false;
				psql_error("unexpected PQresultStatus (%d)",
						   PQresultStatus(result));
				break;
		}

	if (!OK)
	{
		const char *error = PQerrorMessage(pset.db);

		if (strlen(error))
			psql_error("%s", error);

		CheckConnection();
	}

	return OK;
}
开发者ID:dankrusi,项目名称:postgres,代码行数:53,代码来源:common.c


示例13: DisconnectNow

/* Update is run regulary and we gather the state of the Wiiremote and see if the user have pressed on a button or moved the wiiremote
   This could have been done with callbacks instead but it doesn't look nice in C++*/
void CWiiRemote::Update()
{
  if (m_DisconnectWhenPossible)
  {//If the user have choosen to disconnect or lost comunication
    DisconnectNow(true);
    m_DisconnectWhenPossible = false;
  }
#ifdef CWIID_OLD
  if(m_connected)
  {//Here we check if the connection is suddenly broken
    if (!CheckConnection())
    {
      DisconnectNow(true);
      return;
    }
  }
#endif
}
开发者ID:1c0n,项目名称:xbmc,代码行数:20,代码来源:CWIID_WiiRemote.cpp


示例14: GetNextValGTM

/*
 * Get the next sequence value
 */
GTM_Sequence
GetNextValGTM(char *seqname)
{
	GTM_Sequence ret = -1;
	GTM_SequenceKeyData seqkey;
	CheckConnection();
	seqkey.gsk_keylen = strlen(seqname) + 1;
	seqkey.gsk_key = seqname;

	if (conn)
		ret =  get_next(conn, &seqkey);
	if (ret < 0)
	{
		CloseGTM();
		InitGTM();
	}
	return ret;
}
开发者ID:kisehiroshi,项目名称:postgres-xc,代码行数:21,代码来源:gtm.c


示例15: SetValGTM

/*
 * Set values for sequence
 */
int
SetValGTM(char *seqname, GTM_Sequence nextval, bool iscalled)
{
	GTM_SequenceKeyData seqkey;
#ifdef XCP
	char   *coordName = IS_PGXC_COORDINATOR ? PGXCNodeName : MyCoordName;
	int		coordPid = IS_PGXC_COORDINATOR ? MyProcPid : MyCoordPid;
#endif
	CheckConnection();
	seqkey.gsk_keylen = strlen(seqname) + 1;
	seqkey.gsk_key = seqname;

#ifdef XCP
	return conn ? set_val(conn, &seqkey, coordName, coordPid, nextval, iscalled) : -1;
#else
	return conn ? set_val(conn, &seqkey, nextval, iscalled) : -1;
#endif
}
开发者ID:techdragon,项目名称:Postgres-XL,代码行数:21,代码来源:gtm.c


示例16: ProcessCopyResult

/*
 * ProcessCopyResult: if command was a COPY FROM STDIN/TO STDOUT, handle it
 *
 * Note: Utility function for use by SendQuery() only.
 *
 * Returns true if the query executed successfully, false otherwise.
 */
static bool
ProcessCopyResult(PGresult *results)
{
	bool		success = false;

	if (!results)
		return false;

	switch (PQresultStatus(results))
	{
		case PGRES_TUPLES_OK:
		case PGRES_COMMAND_OK:
		case PGRES_EMPTY_QUERY:
			/* nothing to do here */
			success = true;
			break;

		case PGRES_COPY_OUT:
			SetCancelConn();
			success = handleCopyOut(pset.db, pset.queryFout);
			ResetCancelConn();
			break;

		case PGRES_COPY_IN:
			SetCancelConn();
			success = handleCopyIn(pset.db, pset.cur_cmd_source,
								   PQbinaryTuples(results));
			ResetCancelConn();
			break;

		default:
			break;
	}

	/* may need this to recover from conn loss during COPY */
	if (!CheckConnection())
		return false;

	return success;
}
开发者ID:GisKook,项目名称:Gis,代码行数:47,代码来源:common.c


示例17: ProcessCopyResult

/*
 * ProcessCopyResult: if command was a COPY FROM STDIN/TO STDOUT, handle it
 *
 * Note: Utility function for use by SendQuery() only.
 *
 * Returns true if the query executed successfully, false otherwise.
 */
static bool
ProcessCopyResult(PGresult *results)
{
	bool		success = false;

	if (!results)
		return false;

	switch (PQresultStatus(results))
	{
		case PGRES_TUPLES_OK:
		case PGRES_COMMAND_OK:
		case PGRES_EMPTY_QUERY:
			/* nothing to do here */
			success = true;
			break;

		case PGRES_COPY_OUT:
			success = handleCopyOut(pset.db, pset.queryFout);
			break;

		case PGRES_COPY_IN:
			if (pset.cur_cmd_interactive && !QUIET())
				puts(gettext("Enter data to be copied followed by a newline.\n"
							 "End with a backslash and a period on a line by itself."));

			success = handleCopyIn(pset.db, pset.cur_cmd_source,
			  pset.cur_cmd_interactive ? get_prompt(PROMPT_COPY) : NULL);
			break;

		default:
			break;
	}

	/* may need this to recover from conn loss during COPY */
	if (!CheckConnection())
		return false;

	return success;
}
开发者ID:sunyangkobe,项目名称:cscd43,代码行数:47,代码来源:common.c


示例18: PrepareTranGTM

int
PrepareTranGTM(GlobalTransactionId gxid)
{
	int ret;

	if (!GlobalTransactionIdIsValid(gxid))
		return 0;
	CheckConnection();
	ret = prepare_transaction(conn, gxid);

	/*
	 * If something went wrong (timeout), try and reset GTM connection. 
	 * We will close the transaction locally anyway, and closing GTM will force
	 * it to be closed on GTM.
	 */
	if (ret < 0)
	{
		CloseGTM();
		InitGTM();
	}
	return ret;
}
开发者ID:kisehiroshi,项目名称:postgres-xc,代码行数:22,代码来源:gtm.c


示例19: SendCommand

bool cSQL::SendCommand(const String &request)
{
#ifdef NODB
   return true;
#endif
   if (!CheckConnection())
   {
      return false;
   }
   try
   {
      if (mEnableLog)
         log.push_back(Time().TimeString() + "---" + request);
      cmd->CommandText = request;
      cmd->Execute();
      return true;
   }
   catch (Exception &exception)
   {
      return false;
   }
}
开发者ID:firef0xff,项目名称:SQL,代码行数:22,代码来源:SQL.cpp


示例20: BeginTranGTM

GlobalTransactionId
BeginTranGTM(GTM_Timestamp *timestamp)
{
	GlobalTransactionId  xid = InvalidGlobalTransactionId;

	CheckConnection();
	// TODO Isolation level
	if (conn)
		xid =  begin_transaction(conn, GTM_ISOLATION_RC, timestamp);

	/* If something went wrong (timeout), try and reset GTM connection 
	 * and retry. This is safe at the beginning of a transaction.
	 */
	if (!TransactionIdIsValid(xid))
	{
		CloseGTM();
		InitGTM();
		if (conn)
			xid = begin_transaction(conn, GTM_ISOLATION_RC, timestamp);
	}
	return xid;
}
开发者ID:kisehiroshi,项目名称:postgres-xc,代码行数:22,代码来源:gtm.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ CheckDlgButton函数代码示例发布时间:2022-05-30
下一篇:
C++ CheckCondition函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap