blob: d6386e43be5210ecff534601fe6231607ba81533 (
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
// Copyright Epic Games, Inc. All Rights Reserved.
#include "zencore/session.h"
#include <zencore/uid.h>
#include <mutex>
namespace zen {
static Oid GlobalSessionId;
static Oid::String_t GlobalSessionString;
static std::once_flag SessionInitFlag;
static Oid GlobalParentSessionId;
static Oid::String_t GlobalParentSessionString;
static std::mutex GlobalParentSessionMutex;
Oid
GetSessionId()
{
std::call_once(SessionInitFlag, [&] {
GlobalSessionId.Generate();
GlobalSessionId.ToString(GlobalSessionString);
});
return GlobalSessionId;
}
std::string_view
GetSessionIdString()
{
// Ensure we actually have a generated session identifier
std::ignore = GetSessionId();
return std::string_view(GlobalSessionString, Oid::StringLength);
}
void
SetParentSessionId(const Oid& ParentSessionId)
{
std::lock_guard<std::mutex> Lock(GlobalParentSessionMutex);
GlobalParentSessionId = ParentSessionId;
GlobalParentSessionId.ToString(GlobalParentSessionString);
}
Oid
GetParentSessionId()
{
std::lock_guard<std::mutex> Lock(GlobalParentSessionMutex);
return GlobalParentSessionId;
}
std::string_view
GetParentSessionIdString()
{
std::lock_guard<std::mutex> Lock(GlobalParentSessionMutex);
if (GlobalParentSessionId == Oid::Zero)
{
return {};
}
return std::string_view(GlobalParentSessionString, Oid::StringLength);
}
} // namespace zen
|