UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
VVMExecutionContext.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
7
8#if !WITH_VERSE_BPVM
10#endif
11
12namespace verse
13{
14
15#if WITH_VERSE_BPVM
17{
18private:
19 friend struct FExecutionContext;
20
21 FExecutionContextImpl() = default;
22
25
26 COREUOBJECT_API static FExecutionContextImpl* GetCurrent();
27
28 bool bActive = false;
29};
30#endif
31
32// A thread must have an active execution context to run Verse code.
34{
36 : Impl(Other.Impl)
37 {
38 ensure(!bBlockAllExecution);
39 }
40
41#if WITH_VERSE_BPVM
43 {
44 ensure(!bBlockAllExecution);
45 return FExecutionContext(FExecutionContextImpl::Claim());
46 }
47#endif
48
50 {
51 ensure(!bBlockAllExecution);
52#if WITH_VERSE_BPVM
53 return FExecutionContext(FExecutionContextImpl::GetCurrent());
54#else
55 return FExecutionContext(::Verse::FRunningContextPromise{});
56#endif
57 }
58
59#if WITH_VERSE_VM || defined(__INTELLISENSE__)
60 ::Verse::FRunningContext GetContext()
61 {
62 return Impl;
63 }
64#endif
65
67 {
68 bool bWasBlocked = bBlockAllExecution;
69 bBlockAllExecution = ShouldBlock;
70 return bWasBlocked;
71 }
72 static bool IsExecutionBlocked() { return bBlockAllExecution; }
73
74private:
75#if WITH_VERSE_BPVM
77 : Impl(InImpl)
78 {
79 ensureMsgf(Impl != nullptr && Impl->bActive, TEXT("Running Verse code outside of an execution context!"));
80 }
81#else
82 explicit FExecutionContext(::Verse::FRunningContext InImpl)
83 : Impl(InImpl)
84 {
85 }
86#endif
87
88 COREUOBJECT_API static bool bBlockAllExecution;
89
90#if WITH_VERSE_BPVM
92#else
93 ::Verse::FRunningContext Impl;
94#endif
95};
96
97} // namespace verse
#define ensureMsgf( InExpression, InFormat,...)
Definition AssertionMacros.h:465
#define ensure( InExpression)
Definition AssertionMacros.h:464
#define TEXT(x)
Definition Platform.h:1272
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
Definition ExpressionParserTypes.h:21
Definition VVMContentScope.cpp:14
Definition VVMExecutionContext.h:34
FExecutionContext(const FExecutionContext &Other)
Definition VVMExecutionContext.h:35
static bool SetBlockExecution(bool ShouldBlock)
Definition VVMExecutionContext.h:66
static bool IsExecutionBlocked()
Definition VVMExecutionContext.h:72
static FExecutionContext GetActiveContext()
Definition VVMExecutionContext.h:49