Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit13682d8

Browse files
committed
Add bgwpool
1 parent5c4fd94 commit13682d8

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

‎contrib/multimaster/bgwpool.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ static void BgwMainLoop(Datum arg)
2020
PGSemaphoreLock(&pool->available);
2121
SpinLockAcquire(&pool->lock);
2222
Assert(pool->head!=pool->tail);
23-
size= (int*)&pool->buf[pool->head];
23+
size= (int*)&pool->queue[pool->head];
2424
void*work=palloc(len);
2525
if (pool->head+size+4>pool->size) {
26-
memcpy(work,pool->buf,size);
26+
memcpy(work,pool->queue,size);
2727
pool->head= (size&3)& ~3;
2828
}else {
29-
memcpy(work,&pool->buf[pool->head+4],size);
29+
memcpy(work,&pool->queue[pool->head+4],size);
3030
pool->head+=4+ ((size&3)& ~3);
3131
}
3232
if (pool->size==pool->head) {
@@ -42,11 +42,11 @@ static void BgwMainLoop(Datum arg)
4242
}
4343
}
4444

45-
BGWPool*BgwPoolCreate(BgwExecutorexecutor,charconst*dbname,size_tbufSize,size_tnWorkers);
45+
BGWPool*BgwPoolCreate(BgwExecutorexecutor,charconst*dbname,size_tqueueSize,size_tnWorkers);
4646
{
4747
inti;
4848
BackgroundWorkerworker;
49-
BGWPool*pool= (BGWPool*)ShmemAlloc(bufSize+sizeof(BGWPool));
49+
BGWPool*pool= (BGWPool*)ShmemAlloc(queueSize+sizeof(BGWPool));
5050
pool->executor=executor;
5151
PGSemaphoreCreate(&pool->available);
5252
PGSemaphoreCreate(&pool->overflow);
@@ -56,7 +56,7 @@ BGWPool* BgwPoolCreate(BgwExecutor executor, char const* dbname, size_t bufSize,
5656
pool->producerBlocked= false;
5757
pool->head=0;
5858
pool->tail=0;
59-
pool->size=bufSize;
59+
pool->size=queueSize;
6060
strcpy(pool->dbname,dbname);
6161

6262
MemSet(&worker,0,sizeof(BackgroundWorker));
@@ -90,12 +90,12 @@ void BgwPoolExecute(BgwPool* pool, void* work, size_t size);
9090
PGSemaphoreLock(&pool->overflow);
9191
SpinLockAcquire(&pool->lock);
9292
}else {
93-
*(int*)&pool->buf[pool->tail]=size;
93+
*(int*)&pool->queue[pool->tail]=size;
9494
if (pool->size-pool->tail >=size+4) {
95-
memcpy(&pool->buf[pool->tail+4],work,size);
95+
memcpy(&pool->queue[pool->tail+4],work,size);
9696
pool->tail+=4+ (size+3)& ~3;
9797
}else {
98-
memcpy(pool->buf,work,size);
98+
memcpy(pool->queue,work,size);
9999
pool->tail= (size+3)& ~3;
100100
}
101101
PGSemaphoreUnlock(&pool->available);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp