master
h 48 lines 1.06 KB
Raw
1 /*++
2
3 Copyright (c) Microsoft. All rights reserved.
4
5 Module Name:
6
7 SessionModel.h
8
9 Abstract:
10
11 This file contains the SessionModel definition
12
13 --*/
14 #pragma once
15
16 #include <wslc.h>
17
18 namespace wsl::windows::wslc::models {
19
20 struct Session
21 {
22 NON_COPYABLE(Session);
23 DEFAULT_MOVABLE(Session);
24
25 explicit Session(wil::com_ptr<IWSLCSession> session) : m_session(std::move(session))
26 {
27 }
28
29 IWSLCSession* Get() const noexcept
30 {
31 return m_session.get();
32 }
33
34 // Acquires an activity token that keeps the VM alive for the duration of a client-side
35 // container operation (resolve + operate, plus any streamed output). Hold the returned
36 // pointer for the whole operation; releasing it lets the VM idle-terminate again.
37 [[nodiscard]] wil::com_ptr<::IUnknown> BeginContainerOperation() const
38 {
39 wil::com_ptr<::IUnknown> operation;
40 THROW_IF_FAILED(m_session->BeginContainerOperation(&operation));
41 return operation;
42 }
43
44 private:
45 wil::com_ptr<IWSLCSession> m_session;
46 };
47
48 } // namespace wsl::windows::wslc::models