1 | /*------------------------------------------------------------------------- |
2 | * |
3 | * parallel.h |
4 | * |
5 | * Parallel support for pg_dump and pg_restore |
6 | * |
7 | * Portions Copyright (c) 1996-2019, 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 "pg_backup_archiver.h" |
20 | |
21 | /* Function to call in master process on completion of a worker task */ |
22 | typedef void (*ParallelCompletionPtr) (ArchiveHandle *AH, |
23 | TocEntry *te, |
24 | int status, |
25 | void *callback_data); |
26 | |
27 | /* Wait options for WaitForWorkers */ |
28 | typedef enum |
29 | { |
30 | WFW_NO_WAIT, |
31 | WFW_GOT_STATUS, |
32 | WFW_ONE_IDLE, |
33 | WFW_ALL_IDLE |
34 | } WFW_WaitOption; |
35 | |
36 | /* ParallelSlot is an opaque struct known only within parallel.c */ |
37 | typedef struct ParallelSlot ParallelSlot; |
38 | |
39 | /* Overall state for parallel.c */ |
40 | typedef struct ParallelState |
41 | { |
42 | int numWorkers; /* allowed number of workers */ |
43 | /* these arrays have numWorkers entries, one per worker: */ |
44 | TocEntry **te; /* item being worked on, or NULL */ |
45 | ParallelSlot *parallelSlot; /* private info about each worker */ |
46 | } ParallelState; |
47 | |
48 | #ifdef WIN32 |
49 | extern bool parallel_init_done; |
50 | extern DWORD mainThreadId; |
51 | #endif |
52 | |
53 | extern void init_parallel_dump_utils(void); |
54 | |
55 | extern bool IsEveryWorkerIdle(ParallelState *pstate); |
56 | extern void WaitForWorkers(ArchiveHandle *AH, ParallelState *pstate, |
57 | WFW_WaitOption mode); |
58 | |
59 | extern ParallelState *ParallelBackupStart(ArchiveHandle *AH); |
60 | extern void DispatchJobForTocEntry(ArchiveHandle *AH, |
61 | ParallelState *pstate, |
62 | TocEntry *te, |
63 | T_Action act, |
64 | ParallelCompletionPtr callback, |
65 | void *callback_data); |
66 | extern void ParallelBackupEnd(ArchiveHandle *AH, ParallelState *pstate); |
67 | |
68 | extern void set_archive_cancel_info(ArchiveHandle *AH, PGconn *conn); |
69 | |
70 | #endif /* PG_DUMP_PARALLEL_H */ |
71 | |