PostgreSQL Source Code: src/bin/pg_dump/parallel.h Source File

PostgreSQL Source Code git master
parallel.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * parallel.h
4 *
5 * Parallel support for pg_dump and pg_restore
6 *
7 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 * IDENTIFICATION
11 * src/bin/pg_dump/parallel.h
12 *
13 *-------------------------------------------------------------------------
14 */
15
16#ifndef PG_DUMP_PARALLEL_H
17#define PG_DUMP_PARALLEL_H
18
19#include <limits.h>
20
21#include "pg_backup_archiver.h"
22
23/* Function to call in leader process on completion of a worker task */
24 typedef void (*ParallelCompletionPtr) (ArchiveHandle *AH,
25 TocEntry *te,
26 int status,
27 void *callback_data);
28
29/* Wait options for WaitForWorkers */
30 typedef enum
31{
32 WFW_NO_WAIT,
33 WFW_GOT_STATUS,
34 WFW_ONE_IDLE,
35 WFW_ALL_IDLE,
36} WFW_WaitOption;
37
38/*
39 * Maximum number of parallel jobs allowed.
40 *
41 * On Windows we can only have at most MAXIMUM_WAIT_OBJECTS (= 64 usually)
42 * parallel jobs because that's the maximum limit for the
43 * WaitForMultipleObjects() call.
44 */
45#ifdef WIN32
46#define PG_MAX_JOBS MAXIMUM_WAIT_OBJECTS
47#else
48 #define PG_MAX_JOBS INT_MAX
49#endif
50
51/* ParallelSlot is an opaque struct known only within parallel.c */
52 typedef struct ParallelSlot ParallelSlot;
53
54/* Overall state for parallel.c */
55 typedef struct ParallelState
56{
57 int numWorkers; /* allowed number of workers */
58 /* these arrays have numWorkers entries, one per worker: */
59 TocEntry **te; /* item being worked on, or NULL */
60 ParallelSlot *parallelSlot; /* private info about each worker */
61 } ParallelState;
62
63#ifdef WIN32
64extern bool parallel_init_done;
65extern DWORD mainThreadId;
66#endif
67
68extern void init_parallel_dump_utils(void);
69
70extern bool IsEveryWorkerIdle(ParallelState *pstate);
71extern void WaitForWorkers(ArchiveHandle *AH, ParallelState *pstate,
72 WFW_WaitOption mode);
73
74extern ParallelState *ParallelBackupStart(ArchiveHandle *AH);
75extern void DispatchJobForTocEntry(ArchiveHandle *AH,
76 ParallelState *pstate,
77 TocEntry *te,
78 T_Action act,
79 ParallelCompletionPtr callback,
80 void *callback_data);
81extern void ParallelBackupEnd(ArchiveHandle *AH, ParallelState *pstate);
82
83extern void set_archive_cancel_info(ArchiveHandle *AH, PGconn *conn);
84
85#endif /* PG_DUMP_PARALLEL_H */
void ParallelBackupEnd(ArchiveHandle *AH, ParallelState *pstate)
Definition: parallel.c:1061
void WaitForWorkers(ArchiveHandle *AH, ParallelState *pstate, WFW_WaitOption mode)
Definition: parallel.c:1453
ParallelState * ParallelBackupStart(ArchiveHandle *AH)
Definition: parallel.c:899
void(* ParallelCompletionPtr)(ArchiveHandle *AH, TocEntry *te, int status, void *callback_data)
Definition: parallel.h:24
WFW_WaitOption
Definition: parallel.h:31
@ WFW_ALL_IDLE
Definition: parallel.h:35
@ WFW_GOT_STATUS
Definition: parallel.h:33
@ WFW_NO_WAIT
Definition: parallel.h:32
@ WFW_ONE_IDLE
Definition: parallel.h:34
void DispatchJobForTocEntry(ArchiveHandle *AH, ParallelState *pstate, TocEntry *te, T_Action act, ParallelCompletionPtr callback, void *callback_data)
Definition: parallel.c:1207
void init_parallel_dump_utils(void)
Definition: parallel.c:238
bool IsEveryWorkerIdle(ParallelState *pstate)
Definition: parallel.c:1270
struct ParallelState ParallelState
void set_archive_cancel_info(ArchiveHandle *AH, PGconn *conn)
Definition: parallel.c:732
T_Action
static PgChecksumMode mode
Definition: pg_checksums.c:55
PGconn * conn
Definition: streamutil.c:52
TocEntry ** te
Definition: parallel.h:59
ParallelSlot * parallelSlot
Definition: parallel.h:60
int numWorkers
Definition: parallel.h:57
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
Definition: test_ifaddrs.c:46

AltStyle によって変換されたページ (->オリジナル) /