Files
UnrealEngineUWP/Engine/Source/Runtime/Messaging/Private/Bus/MessageDispatchTask.h
ryan gerleve b41214417e Resolving conflict from Dev-Enterprise.
/src/ROBOMERGE_ENGINE_Dev_Networking/Engine/Source/Runtime/Sockets/Private/BSDSockets/SocketsBSD.cpp - merging //UE4/Main/Engine/Source/Runtime/Sockets/Private/BSDSockets/SocketsBSD.cpp#20


--------------------------------------
Copying //UE4/Dev-Enterprise[at]4705006 to Dev-Main (//UE4/Dev-Main)

#rb none
#lockdown Nick.Penwarden

#ROBOMERGE-OWNER: ryan.gerleve
#ROBOMERGE-AUTHOR: francis.hurteau
#ROBOMERGE-SOURCE: CL 4705151 in //UE4/Main/...
#ROBOMERGE-BOT: ENGINE (Main -> Dev-Networking)

[CL 4712032 by ryan gerleve in Dev-Networking branch]
2019-01-11 14:26:15 -05:00

153 lines
3.7 KiB
C++

// Copyright 1998-2019 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Stats/Stats.h"
#include "IMessageContext.h"
#include "IMessageBusListener.h"
#include "Bus/MessageTracer.h"
class IMessageReceiver;
/**
* Implements an asynchronous task for dispatching a message to a recipient.
*/
class FMessageDispatchTask
{
public:
/**
* Creates and initializes a new instance.
*
* @param InThread The name of the thread to dispatch the message on.
* @param InContext The context of the message to dispatch.
* @param InRecipient The message recipient.
* @param InTracer The message tracer to notify.
*/
FMessageDispatchTask(
ENamedThreads::Type InThread,
TSharedRef<IMessageContext, ESPMode::ThreadSafe> InContext,
TWeakPtr<IMessageReceiver, ESPMode::ThreadSafe> InRecipient,
TSharedPtr<FMessageTracer, ESPMode::ThreadSafe> InTracer);
public:
/**
* Performs the actual task.
*
* @param CurrentThread The thread that this task is executing on.
* @param MyCompletionGraphEvent The completion event.
*/
void DoTask(ENamedThreads::Type CurrentThread, const FGraphEventRef& MyCompletionGraphEvent);
/**
* Returns the name of the thread that this task should run on.
*
* @return Thread name.
*/
ENamedThreads::Type GetDesiredThread()
{
return Thread;
}
/**
* Gets the task's stats tracking identifier.
*
* @return Stats identifier.
*/
TStatId GetStatId() const;
/**
* Gets the mode for tracking subsequent tasks.
*
* @return Always track subsequent tasks.
*/
static ESubsequentsMode::Type GetSubsequentsMode()
{
return ESubsequentsMode::TrackSubsequents;
}
private:
/** Holds the message context. */
TSharedRef<IMessageContext, ESPMode::ThreadSafe> Context;
/** Holds a reference to the recipient. */
TWeakPtr<IMessageReceiver, ESPMode::ThreadSafe> RecipientPtr;
/** Holds the name of the thread that the router is running on. */
ENamedThreads::Type Thread;
/** Holds a pointer to the message tracer. */
TWeakPtr<FMessageTracer, ESPMode::ThreadSafe> TracerPtr;
};
/**
* Implements an asynchronous task for dispatching a registration notification to a listener.
*/
class FBusNotificationDispatchTask
{
public:
/**
* Creates and initializes a new instance.
*
* @param InThread The name of the thread to dispatch the message on.
* @param InListener The listener to notify.
* @param InAddress The address we are notifying about.
* @param InNotification The notification type being notified.
*/
FBusNotificationDispatchTask(
ENamedThreads::Type InThread,
TWeakPtr<IBusListener, ESPMode::ThreadSafe> InListener,
FMessageAddress InAddress,
EMessageBusNotification InNotification)
: Thread(InThread)
, ListenerPtr(InListener)
, Address(InAddress)
, Notification(InNotification)
{}
public:
/**
* Performs the actual task.
*
* @param CurrentThread The thread that this task is executing on.
* @param MyCompletionGraphEvent The completion event.
*/
void DoTask(ENamedThreads::Type CurrentThread, const FGraphEventRef& MyCompletionGraphEvent);
/**
* Returns the name of the thread that this task should run on.
*
* @return Thread name.
*/
ENamedThreads::Type GetDesiredThread()
{
return Thread;
}
TStatId GetStatId() const;
static ESubsequentsMode::Type GetSubsequentsMode()
{
return ESubsequentsMode::TrackSubsequents;
}
private:
/** Holds the name of the thread that the router is running on. */
ENamedThreads::Type Thread;
/** Holds a reference to the recipient. */
TWeakPtr<IBusListener, ESPMode::ThreadSafe> ListenerPtr;
/** Holds the address we are notifying about. */
FMessageAddress Address;
/** Holds the notification type we are notifying about. */
EMessageBusNotification Notification;
};