summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/os_win/os_sleep.c
blob: 448447f35ef3108a405fd48ee4db60f8f5a3a750 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*-
 * Copyright (c) 2014-2018 MongoDB, Inc.
 * Copyright (c) 2008-2014 WiredTiger, Inc.
 *	All rights reserved.
 *
 * See the file LICENSE for redistribution information.
 */

#include "wt_internal.h"

/*
 * __wt_sleep --
 *	Pause the thread of control.
 */
void
__wt_sleep(uint64_t seconds, uint64_t micro_seconds)
{
	DWORD dwMilliseconds;

	/*
	 * Sleeping isn't documented as a memory barrier, and it's a reasonable
	 * expectation to have. There's no reason not to explicitly include a
	 * barrier since we're giving up the CPU, and ensures callers are never
	 * surprised.
	 */
	WT_FULL_BARRIER();

	/*
	 * If the caller wants a small pause, set to our smallest granularity.
	 */
	if (seconds == 0 && micro_seconds < WT_THOUSAND)
		micro_seconds = WT_THOUSAND;
	dwMilliseconds = (DWORD)
	    (seconds * WT_THOUSAND + micro_seconds / WT_THOUSAND);
	Sleep(dwMilliseconds);
}