aboutsummaryrefslogtreecommitdiff
path: root/src/zenhttp/servers/httpsys_iocontext.h
blob: 4f8a970124fea76e267ba4a7e5bab8abed63f47d (plain) (blame)
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
37
38
39
40
// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#if ZEN_WITH_HTTPSYS
#	define _WINSOCKAPI_
#	include <zencore/windows.h>

#	include <cstdint>

namespace zen {

/**
 * Tagged OVERLAPPED wrapper for http.sys IOCP dispatch
 *
 * Both HttpSysTransaction (for normal HTTP request I/O) and WsHttpSysConnection
 * (for WebSocket read/write) embed this struct.  The single IoCompletionCallback
 * bound to the request queue uses the ContextType tag to dispatch to the correct
 * handler.
 *
 * The Overlapped member must be first so that CONTAINING_RECORD works to recover
 * the HttpSysIoContext from the OVERLAPPED pointer provided by the threadpool.
 */
struct HttpSysIoContext
{
	OVERLAPPED Overlapped{};

	enum class Type : uint8_t
	{
		kTransaction,
		kWebSocketRead,
		kWebSocketWrite,
	} ContextType = Type::kTransaction;

	void* Owner = nullptr;
};

}  // namespace zen

#endif	// ZEN_WITH_HTTPSYS