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-2020, 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; /* Maximum number of workers to launch */
37  int nworkers_to_launch; /* Actual number of workers to launch */
39  char *library_name;
50 
51 typedef struct ParallelWorkerContext
52 {
56 
57 extern volatile bool ParallelMessagePending;
60 
61 #define IsParallelWorker() (ParallelWorkerNumber >= 0)
62 
63 extern ParallelContext *CreateParallelContext(const char *library_name,
64  const char *function_name, int nworkers);
65 extern void InitializeParallelDSM(ParallelContext *pcxt);
66 extern void ReinitializeParallelDSM(ParallelContext *pcxt);
67 extern void ReinitializeParallelWorkers(ParallelContext *pcxt, int nworkers_to_launch);
68 extern void LaunchParallelWorkers(ParallelContext *pcxt);
71 extern void DestroyParallelContext(ParallelContext *pcxt);
72 extern bool ParallelContextActive(void);
73 
74 extern void HandleParallelMessageInterrupt(void);
75 extern void HandleParallelMessages(void);
76 extern void AtEOXact_Parallel(bool isCommit);
77 extern void AtEOSubXact_Parallel(bool isCommit, SubTransactionId mySubId);
78 extern void ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end);
79 
80 extern void ParallelWorkerMain(Datum main_arg);
81 
82 #endif /* PARALLEL_H */
void ReinitializeParallelWorkers(ParallelContext *pcxt, int nworkers_to_launch)
Definition: parallel.c:513
dsm_segment * seg
Definition: parallel.h:43
struct ParallelContext ParallelContext
shm_toc_estimator estimator
Definition: parallel.h:42
int nknown_attached_workers
Definition: parallel.h:47
uint32 SubTransactionId
Definition: c.h:524
void AtEOSubXact_Parallel(bool isCommit, SubTransactionId mySubId)
Definition: parallel.c:1203
int nworkers_to_launch
Definition: parallel.h:37
bool ParallelContextActive(void)
Definition: parallel.c:978
void HandleParallelMessages(void)
Definition: parallel.c:1002
volatile bool ParallelMessagePending
Definition: parallel.c:115
#define PGDLLIMPORT
Definition: c.h:1257
signed int int32
Definition: c.h:362
SubTransactionId subid
Definition: parallel.h:35
ParallelWorkerInfo * worker
Definition: parallel.h:46
char * function_name
Definition: parallel.h:40
shm_mq_handle * error_mqh
Definition: parallel.h:28
PGDLLIMPORT bool InitializingParallelWorker
Definition: parallel.c:118
BackgroundWorkerHandle * bgwhandle
Definition: parallel.h:27
int nworkers_launched
Definition: parallel.h:38
bool * known_attached_workers
Definition: parallel.h:48
void ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
Definition: parallel.c:1493
void AtEOXact_Parallel(bool isCommit)
Definition: parallel.c:1222
uintptr_t Datum
Definition: postgres.h:367
struct ParallelWorkerContext ParallelWorkerContext
char * library_name
Definition: parallel.h:39
uint64 XLogRecPtr
Definition: xlogdefs.h:21
void LaunchParallelWorkers(ParallelContext *pcxt)
Definition: parallel.c:527
void InitializeParallelDSM(ParallelContext *pcxt)
Definition: parallel.c:202
dlist_node node
Definition: parallel.h:34
struct ParallelWorkerInfo ParallelWorkerInfo
ErrorContextCallback * error_context_stack
Definition: parallel.h:41
void WaitForParallelWorkersToAttach(ParallelContext *pcxt)
Definition: parallel.c:647
void(* parallel_worker_main_type)(dsm_segment *seg, shm_toc *toc)
Definition: parallel.h:23
void HandleParallelMessageInterrupt(void)
Definition: parallel.c:991
void ReinitializeParallelDSM(ParallelContext *pcxt)
Definition: parallel.c:463
ParallelContext * CreateParallelContext(const char *library_name, const char *function_name, int nworkers)
Definition: parallel.c:164
void WaitForParallelWorkersToFinish(ParallelContext *pcxt)
Definition: parallel.c:750
void DestroyParallelContext(ParallelContext *pcxt)
Definition: parallel.c:904
PGDLLIMPORT int ParallelWorkerNumber
Definition: parallel.c:112
void ParallelWorkerMain(Datum main_arg)
Definition: parallel.c:1239
dsm_segment * seg
Definition: parallel.h:53
shm_toc * toc
Definition: parallel.h:45
void * private_memory
Definition: parallel.h:44