aboutsummaryrefslogtreecommitdiff
path: root/src/zenhorde/hordecomputechannel.h
blob: c1dff20e490430e0e585b1d884979a1b23704ca0 (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
// Copyright Epic Games, Inc. All Rights Reserved.

#pragma once

#include "hordecomputebuffer.h"

namespace zen::horde {

/** Bidirectional communication channel using a pair of compute buffers.
 *
 *  Pairs a ComputeBufferReader (for receiving data) with a ComputeBufferWriter
 *  (for sending data). Used by ComputeSocket to represent one logical channel
 *  within a multiplexed connection.
 */
class ComputeChannel : public TRefCounted<ComputeChannel>
{
public:
	ComputeBufferReader Reader;
	ComputeBufferWriter Writer;

	ComputeChannel(ComputeBufferReader InReader, ComputeBufferWriter InWriter);

	bool IsValid() const;

	size_t Send(const void* Data, size_t Size, int TimeoutMs = -1);
	size_t Recv(void* Data, size_t Size, int TimeoutMs = -1);

	/** Signal that no more data will be sent on this channel. */
	void MarkComplete();
};

}  // namespace zen::horde