1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-05 00:28:52 +02:00
Files
pgbackrest/src/protocol/parallel.h
David Steele d30ec9c9ae Replace OBJECT_DEFINE_MOVE() and OBJECT_DEFINE_FREE() with inlines.
Inline functions are more efficient and if they are not used are automatically omitted from the binary.

This also makes the implementation of these functions easier to find and removes the need for a declaration. That is, the complete implementation is located in the header rather than being spread between the header and C file.
2021-04-08 10:04:57 -04:00

68 lines
3.7 KiB
C

/***********************************************************************************************************************************
Protocol Parallel Executor
***********************************************************************************************************************************/
#ifndef PROTOCOL_PARALLEL_H
#define PROTOCOL_PARALLEL_H
/***********************************************************************************************************************************
Object type
***********************************************************************************************************************************/
typedef struct ProtocolParallel ProtocolParallel;
#include "common/time.h"
#include "common/type/object.h"
#include "protocol/client.h"
#include "protocol/parallelJob.h"
/***********************************************************************************************************************************
Job request callback
Called whenever a new job is required for processing. If no more jobs are available then NULL is returned. Note that NULL must be
returned to each clientIdx in case job distribution varies by clientIdx.
***********************************************************************************************************************************/
typedef ProtocolParallelJob *ParallelJobCallback(void *data, unsigned int clientIdx);
/***********************************************************************************************************************************
Constructors
***********************************************************************************************************************************/
ProtocolParallel *protocolParallelNew(TimeMSec timeout, ParallelJobCallback *callbackFunction, void *callbackData);
/***********************************************************************************************************************************
Functions
***********************************************************************************************************************************/
// Add client
void protocolParallelClientAdd(ProtocolParallel *this, ProtocolClient *client);
// Process jobs
unsigned int protocolParallelProcess(ProtocolParallel *this);
/***********************************************************************************************************************************
Getters/Setters
***********************************************************************************************************************************/
// Are all jobs done?
bool protocolParallelDone(ProtocolParallel *this);
// Completed job result
ProtocolParallelJob *protocolParallelResult(ProtocolParallel *this);
/***********************************************************************************************************************************
Destructor
***********************************************************************************************************************************/
__attribute__((always_inline)) static inline void
protocolParallelFree(ProtocolParallel *this)
{
objFree(this);
}
/***********************************************************************************************************************************
Macros for function logging
***********************************************************************************************************************************/
String *protocolParallelToLog(const ProtocolParallel *this);
#define FUNCTION_LOG_PROTOCOL_PARALLEL_TYPE \
ProtocolParallel *
#define FUNCTION_LOG_PROTOCOL_PARALLEL_FORMAT(value, buffer, bufferSize) \
FUNCTION_LOG_STRING_OBJECT_FORMAT(value, protocolParallelToLog, buffer, bufferSize)
#endif