PostgreSQL Source Code git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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-2024, 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
23typedef void (*parallel_worker_main_type) (dsm_segment *seg, shm_toc *toc);
24
25typedef struct ParallelWorkerInfo
26{
30
31typedef struct ParallelContext
32{
35 int nworkers; /* Maximum number of workers to launch */
36 int nworkers_to_launch; /* Actual number of workers to launch */
49
51{
55
56extern PGDLLIMPORT volatile sig_atomic_t ParallelMessagePending;
59
60#define IsParallelWorker() (ParallelWorkerNumber >= 0)
61
62extern ParallelContext *CreateParallelContext(const char *library_name,
63 const char *function_name, int nworkers);
64extern void InitializeParallelDSM(ParallelContext *pcxt);
66extern void ReinitializeParallelWorkers(ParallelContext *pcxt, int nworkers_to_launch);
67extern void LaunchParallelWorkers(ParallelContext *pcxt);
71extern bool ParallelContextActive(void);
72
73extern void HandleParallelMessageInterrupt(void);
74extern void HandleParallelMessages(void);
75extern void AtEOXact_Parallel(bool isCommit);
76extern void AtEOSubXact_Parallel(bool isCommit, SubTransactionId mySubId);
77extern void ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end);
78
79extern void ParallelWorkerMain(Datum main_arg);
80
81#endif /* PARALLEL_H */
#define PGDLLIMPORT
Definition: c.h:1274
uint32 SubTransactionId
Definition: c.h:610
PGDLLIMPORT volatile sig_atomic_t ParallelMessagePending
Definition: parallel.c:117
void HandleParallelMessageInterrupt(void)
Definition: parallel.c:1033
void InitializeParallelDSM(ParallelContext *pcxt)
Definition: parallel.c:207
PGDLLIMPORT int ParallelWorkerNumber
Definition: parallel.c:114
void WaitForParallelWorkersToFinish(ParallelContext *pcxt)
Definition: parallel.c:792
void LaunchParallelWorkers(ParallelContext *pcxt)
Definition: parallel.c:569
void ReinitializeParallelDSM(ParallelContext *pcxt)
Definition: parallel.c:504
void HandleParallelMessages(void)
Definition: parallel.c:1044
void DestroyParallelContext(ParallelContext *pcxt)
Definition: parallel.c:946
void ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
Definition: parallel.c:1582
PGDLLIMPORT bool InitializingParallelWorker
Definition: parallel.c:120
ParallelContext * CreateParallelContext(const char *library_name, const char *function_name, int nworkers)
Definition: parallel.c:169
bool ParallelContextActive(void)
Definition: parallel.c:1020
void ParallelWorkerMain(Datum main_arg)
Definition: parallel.c:1288
void(* parallel_worker_main_type)(dsm_segment *seg, shm_toc *toc)
Definition: parallel.h:23
struct ParallelWorkerContext ParallelWorkerContext
void ReinitializeParallelWorkers(ParallelContext *pcxt, int nworkers_to_launch)
Definition: parallel.c:554
struct ParallelContext ParallelContext
void WaitForParallelWorkersToAttach(ParallelContext *pcxt)
Definition: parallel.c:689
struct ParallelWorkerInfo ParallelWorkerInfo
void AtEOSubXact_Parallel(bool isCommit, SubTransactionId mySubId)
Definition: parallel.c:1250
void AtEOXact_Parallel(bool isCommit)
Definition: parallel.c:1271
uintptr_t Datum
Definition: postgres.h:64
char * library_name
Definition: parallel.h:38
dsm_segment * seg
Definition: parallel.h:42
bool * known_attached_workers
Definition: parallel.h:47
ErrorContextCallback * error_context_stack
Definition: parallel.h:40
SubTransactionId subid
Definition: parallel.h:34
shm_toc_estimator estimator
Definition: parallel.h:41
int nknown_attached_workers
Definition: parallel.h:46
ParallelWorkerInfo * worker
Definition: parallel.h:45
shm_toc * toc
Definition: parallel.h:44
dlist_node node
Definition: parallel.h:33
void * private_memory
Definition: parallel.h:43
int nworkers_launched
Definition: parallel.h:37
int nworkers_to_launch
Definition: parallel.h:36
char * function_name
Definition: parallel.h:39
dsm_segment * seg
Definition: parallel.h:52
BackgroundWorkerHandle * bgwhandle
Definition: parallel.h:27
shm_mq_handle * error_mqh
Definition: parallel.h:28
uint64 XLogRecPtr
Definition: xlogdefs.h:21