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


C++ QueueItem::exec方法代码示例

本文整理汇总了C++中QueueItem::exec方法的典型用法代码示例。如果您正苦于以下问题:C++ QueueItem::exec方法的具体用法?C++ QueueItem::exec怎么用?C++ QueueItem::exec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QueueItem的用法示例。


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

示例1: linitial

/*
 * recv_writer_queue - return the number of queued items
 */
static int
recv_writer_queue(void)
{
	PGconn	   *conn;
	List	   *queue;
	int			ret;
	char	   *instid = NULL;
	bool		connection_used = false;

	pthread_mutex_lock(&writer_queue_lock);
	queue = writer_queue;
	writer_queue = NIL;
	pthread_mutex_unlock(&writer_queue_lock);

	if (list_length(queue) == 0)
		return 0;

	/* install writer schema */
	if ((conn = writer_connect(superuser_connect)) == NULL)
	{
		elog(ERROR, "could not connect to repository");

		/* discard current queue if can't connect to repository */
		if (list_length(queue) > 0)
		{
			elog(WARNING, "writer discards %d items", list_length(queue));
			list_destroy(queue, destroy_writer_queue);
		}
		return 0;
	}

	/* do the writer queue process */
	if ((instid = get_instid(conn)) != NULL)
	{
		connection_used = true;

		while (list_length(queue) > 0)
		{
			QueueItem  *item = (QueueItem *) linitial(queue);

			if (!item->exec(item, conn, instid))
			{
				if (++item->retry < DB_MAX_RETRY)
					break;	/* retry the item */

				/*
				 * discard if the retry count is exceeded to avoid infinite
				 * loops at one bad item.
				 */
				elog(WARNING, "writer discard an item");
			}

			item->free(item);
			queue = list_delete_first(queue);
		}
	}
	free(instid);

	/* delay on error */
	if (list_length(queue) > 0)
		delay();

	/*
	 * When we have failed items, we concatenate to the head of writer queue
	 * and retry them in the next cycle.
	 */
	pthread_mutex_lock(&writer_queue_lock);
	writer_queue = list_concat(queue, writer_queue);
	ret = list_length(writer_queue);
	pthread_mutex_unlock(&writer_queue_lock);

	/* update last used time of the connection. */
	if (connection_used)
		writer_conn_last_used = time(NULL);

	return ret;
}
开发者ID:mitsu-ko,项目名称:pg_statsinfo,代码行数:80,代码来源:writer.c


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