Files
UnrealEngineUWP/Engine/Source/Programs/Horde/Samples/RemoteWorkerCpp/Main.cpp
Ben Marsh da8149d19b Horde: Various compute API improvements.
* All standard buffers now implement IComputeBuffer directly, and do not need to have ToSharedInstance() called to create a ref-counted version.
* Workers can now construct a socket directly, allowing multiple buffers to be attached.
* Control messages are sent whenever a receive buffer is attached, allowing the remote to wait for it to be available.

#preflight none

[CL 25169238 by Ben Marsh in ue5-main branch]
2023-04-24 15:21:04 -04:00

49 lines
832 B
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include <iostream>
#include "ComputeChannel.h"
#include "SharedMemoryBuffer.h"
int main()
{
FComputeSocket Socket;
if (!Socket.Open())
{
std::cout << "Environment variable not set correctly" << std::endl;
return 1;
}
FComputeChannel Channel;
if (!Channel.Open(Socket, FComputeChannel::DefaultWorkerChannelId))
{
std::cout << "Unable to create channel to host" << std::endl;
return 1;
}
std::cout << "Connected to client" << std::endl;
size_t Length = 0;
char Buffer[4];
for (;;)
{
size_t Read = Channel.Receive(Buffer + Length, sizeof(Buffer) - Length);
if (Read == 0)
{
return 0;
}
Length += Read;
if (Length >= 4)
{
std::cout << "Read value " << *(int*)Buffer << std::endl;
Length = 0;
}
}
Channel.Close();
return 0;
}