本文整理汇总了C++中QueueItem::free方法的典型用法代码示例。如果您正苦于以下问题:C++ QueueItem::free方法的具体用法?C++ QueueItem::free怎么用?C++ QueueItem::free使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueueItem
的用法示例。
在下文中一共展示了QueueItem::free方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: worker_post
/*
* Do clean-up and notifications in the main thread
*/
static bool worker_post(gpointer _wj)
{
WorkerJob* wj = _wj;
QueueItem* job = wj->job;
WfWorker* w = wj->worker;
if(!job->cancelled){
Waveform* waveform = g_weak_ref_get(&job->ref);
call(job->done, waveform, NULL, job->user_data);
if(waveform) g_object_unref(waveform);
}
if(job->free && job->user_data){
job->free(job->user_data);
job->user_data = NULL;
}
w->jobs = g_list_remove(w->jobs, job);
g_weak_ref_set(&job->ref, NULL);
g_free(job);
g_free(wj);
return G_SOURCE_REMOVE;
}
示例2: 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;
}