Blame source/uds/requestQueue.h

Packit b55c50
/*
Packit b55c50
 * Copyright (c) 2020 Red Hat, Inc.
Packit b55c50
 *
Packit b55c50
 * This program is free software; you can redistribute it and/or
Packit b55c50
 * modify it under the terms of the GNU General Public License
Packit b55c50
 * as published by the Free Software Foundation; either version 2
Packit b55c50
 * of the License, or (at your option) any later version.
Packit b55c50
 * 
Packit b55c50
 * This program is distributed in the hope that it will be useful,
Packit b55c50
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit b55c50
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit b55c50
 * GNU General Public License for more details.
Packit b55c50
 * 
Packit b55c50
 * You should have received a copy of the GNU General Public License
Packit b55c50
 * along with this program; if not, write to the Free Software
Packit b55c50
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Packit b55c50
 * 02110-1301, USA. 
Packit b55c50
 *
Packit b55c50
 * $Id: //eng/uds-releases/jasper/src/uds/requestQueue.h#1 $
Packit b55c50
 */
Packit b55c50
Packit b55c50
#ifndef REQUEST_QUEUE_H
Packit b55c50
#define REQUEST_QUEUE_H
Packit b55c50
Packit b55c50
#include "opaqueTypes.h"
Packit b55c50
#include "typeDefs.h"
Packit b55c50
Packit b55c50
/* void return value because this function will process its own errors */
Packit b55c50
typedef void RequestQueueProcessor(Request *);
Packit b55c50
Packit b55c50
/**
Packit b55c50
 * Allocate a new request processing queue and start a worker thread to
Packit b55c50
 * consume and service requests in the queue.
Packit b55c50
 *
Packit b55c50
 * @param queueName   the name of the queue and the worker thread
Packit b55c50
 * @param processOne  the function the worker will invoke on each request
Packit b55c50
 * @param queuePtr    a pointer to receive the new queue
Packit b55c50
 *
Packit b55c50
 * @return UDS_SUCCESS or an error code
Packit b55c50
 **/
Packit b55c50
int makeRequestQueue(const char             *queueName,
Packit b55c50
                     RequestQueueProcessor  *processOne,
Packit b55c50
                     RequestQueue          **queuePtr)
Packit b55c50
  __attribute__((warn_unused_result));
Packit b55c50
Packit b55c50
/**
Packit b55c50
 * Add a request to the end of the queue for processing by the worker thread.
Packit b55c50
 * If the requeued flag is set on the request, it will be processed before
Packit b55c50
 * any non-requeued requests under most circumstances.
Packit b55c50
 *
Packit b55c50
 * @param queue    the request queue that should process the request
Packit b55c50
 * @param request  the request to be processed on the queue's worker thread
Packit b55c50
 **/
Packit b55c50
void requestQueueEnqueue(RequestQueue *queue, Request *request);
Packit b55c50
Packit b55c50
/**
Packit b55c50
 * Shut down the request queue worker thread, then destroy and free the queue.
Packit b55c50
 *
Packit b55c50
 * @param queue  the queue to shut down and free
Packit b55c50
 **/
Packit b55c50
void requestQueueFinish(RequestQueue *queue);
Packit b55c50
Packit b55c50
#endif /* REQUEST_QUEUE_H */