PostgreSQL Source Code  git master
parallel.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * parallel.h
4  * Infrastructure for launching parallel workers
5  *
6  * Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
7  * Portions Copyright (c) 1994, Regents of the University of California
8  *
9  * src/include/access/parallel.h
10  *
11  *-------------------------------------------------------------------------
12  */
13 
14 #ifndef PARALLEL_H
15 #define PARALLEL_H
16 
17 #include "access/xlogdefs.h"
18 #include "lib/ilist.h"
19 #include "postmaster/bgworker.h"
20 #include "storage/shm_mq.h"
21 #include "storage/shm_toc.h"
22 
23 typedef void (*parallel_worker_main_type) (dsm_segment *seg, shm_toc *toc);
24 
25 typedef struct ParallelWorkerInfo
26 {
31 
32 typedef struct ParallelContext
33 {
36  int nworkers;
38  char *library_name;
49 
50 typedef struct ParallelWorkerContext
51 {
55 
56 extern volatile bool ParallelMessagePending;
59 
60 #define IsParallelWorker() (ParallelWorkerNumber >= 0)
61 
62 extern ParallelContext *CreateParallelContext(const char *library_name,
63  const char *function_name, int nworkers);
64 extern void InitializeParallelDSM(ParallelContext *pcxt);
65 extern void ReinitializeParallelDSM(ParallelContext *pcxt);
66 extern void LaunchParallelWorkers(ParallelContext *pcxt);
69 extern void DestroyParallelContext(ParallelContext *pcxt);
70 extern bool ParallelContextActive(void);
71 
72 extern void HandleParallelMessageInterrupt(void);
73 extern void HandleParallelMessages(void);
74 extern void AtEOXact_Parallel(bool isCommit);
75 extern void AtEOSubXact_Parallel(bool isCommit, SubTransactionId mySubId);
76 extern void ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end);
77 
78 extern void ParallelWorkerMain(Datum main_arg);
79 
80 #endif /* PARALLEL_H */
dsm_segment * seg
Definition: parallel.h:42
struct ParallelContext ParallelContext
shm_toc_estimator estimator
Definition: parallel.h:41
int nknown_attached_workers
Definition: parallel.h:46
uint32 SubTransactionId
Definition: c.h:512
void AtEOSubXact_Parallel(bool isCommit, SubTransactionId mySubId)
Definition: parallel.c:1169
bool ParallelContextActive(void)
Definition: parallel.c:944
void HandleParallelMessages(void)
Definition: parallel.c:968
volatile bool ParallelMessagePending
Definition: parallel.c:112
#define PGDLLIMPORT
Definition: c.h:1266
signed int int32
Definition: c.h:347
SubTransactionId subid
Definition: parallel.h:35
ParallelWorkerInfo * worker
Definition: parallel.h:45
char * function_name
Definition: parallel.h:39
shm_mq_handle * error_mqh
Definition: parallel.h:28
PGDLLIMPORT bool InitializingParallelWorker
Definition: parallel.c:115
BackgroundWorkerHandle * bgwhandle
Definition: parallel.h:27
int nworkers_launched
Definition: parallel.h:37
bool * known_attached_workers
Definition: parallel.h:47
void ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
Definition: parallel.c:1453
void AtEOXact_Parallel(bool isCommit)
Definition: parallel.c:1188
uintptr_t Datum
Definition: postgres.h:367
struct ParallelWorkerContext ParallelWorkerContext
char * library_name
Definition: parallel.h:38
uint64 XLogRecPtr
Definition: xlogdefs.h:21
void LaunchParallelWorkers(ParallelContext *pcxt)
Definition: parallel.c:493
void InitializeParallelDSM(ParallelContext *pcxt)
Definition: parallel.c:195
dlist_node node
Definition: parallel.h:34
struct ParallelWorkerInfo ParallelWorkerInfo
ErrorContextCallback * error_context_stack
Definition: parallel.h:40
void WaitForParallelWorkersToAttach(ParallelContext *pcxt)
Definition: parallel.c:613
void(* parallel_worker_main_type)(dsm_segment *seg, shm_toc *toc)
Definition: parallel.h:23
void HandleParallelMessageInterrupt(void)
Definition: parallel.c:957
void ReinitializeParallelDSM(ParallelContext *pcxt)
Definition: parallel.c:446
ParallelContext * CreateParallelContext(const char *library_name, const char *function_name, int nworkers)
Definition: parallel.c:158
void WaitForParallelWorkersToFinish(ParallelContext *pcxt)
Definition: parallel.c:716
void DestroyParallelContext(ParallelContext *pcxt)
Definition: parallel.c:870
PGDLLIMPORT int ParallelWorkerNumber
Definition: parallel.c:109
void ParallelWorkerMain(Datum main_arg)
Definition: parallel.c:1205
dsm_segment * seg
Definition: parallel.h:52
shm_toc * toc
Definition: parallel.h:44
void * private_memory
Definition: parallel.h:43