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

Commit3338a98

Browse files
committed
test_shm_mq: Replace WAIT_EVENT_EXTENSION with custom wait events
Two custom wait events are added here:- "TestShmMqBgWorkerStartup", when setting up a set of bgworkers inwait_for_workers_to_become_ready().- "TestShmMqMessageQueue", when waiting for a queued message intest_shm_mq_pipelined().Author: Masahiro IkedaDiscussion:https://postgr.es/m/197bce267fa691a0ac62c86c4ab904c4@oss.nttdata.com
1 parentc8e318b commit3338a98

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

‎src/test/modules/test_shm_mq/setup.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ static void wait_for_workers_to_become_ready(worker_state *wstate,
4040
volatiletest_shm_mq_header*hdr);
4141
staticboolcheck_worker_status(worker_state*wstate);
4242

43+
/* value cached, fetched from shared memory */
44+
staticuint32we_bgworker_startup=0;
45+
4346
/*
4447
* Set up a dynamic shared memory segment and zero or more background workers
4548
* for a test run.
@@ -278,9 +281,13 @@ wait_for_workers_to_become_ready(worker_state *wstate,
278281
break;
279282
}
280283

284+
/* first time, allocate or get the custom wait event */
285+
if (we_bgworker_startup==0)
286+
we_bgworker_startup=WaitEventExtensionNew("TestShmMqBgWorkerStartup");
287+
281288
/* Wait to be signaled. */
282289
(void)WaitLatch(MyLatch,WL_LATCH_SET |WL_EXIT_ON_PM_DEATH,0,
283-
WAIT_EVENT_EXTENSION);
290+
we_bgworker_startup);
284291

285292
/* Reset the latch so we don't spin. */
286293
ResetLatch(MyLatch);

‎src/test/modules/test_shm_mq/test.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ PG_FUNCTION_INFO_V1(test_shm_mq_pipelined);
2828
staticvoidverify_message(Sizeoriglen,char*origdata,Sizenewlen,
2929
char*newdata);
3030

31+
/* value cached, fetched from shared memory */
32+
staticuint32we_message_queue=0;
33+
3134
/*
3235
* Simple test of the shared memory message queue infrastructure.
3336
*
@@ -225,14 +228,18 @@ test_shm_mq_pipelined(PG_FUNCTION_ARGS)
225228

226229
if (wait)
227230
{
231+
/* first time, allocate or get the custom wait event */
232+
if (we_message_queue==0)
233+
we_message_queue=WaitEventExtensionNew("TestShmMqMessageQueue");
234+
228235
/*
229236
* If we made no progress, wait for one of the other processes to
230237
* which we are connected to set our latch, indicating that they
231238
* have read or written data and therefore there may now be work
232239
* for us to do.
233240
*/
234241
(void)WaitLatch(MyLatch,WL_LATCH_SET |WL_EXIT_ON_PM_DEATH,0,
235-
WAIT_EVENT_EXTENSION);
242+
we_message_queue);
236243
ResetLatch(MyLatch);
237244
CHECK_FOR_INTERRUPTS();
238245
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp