% SessionInfo Metadata about a parallel.Pool session

%   Copyright 2020 The MathWorks, Inc.
classdef SessionInfo
    
    properties
        ProfileName (1,1) string = ""
        ClusterType (1,1) string = ""
        State (1,1) parallel.internal.pool.SessionState = ...
            parallel.internal.pool.SessionState.CLOSED
        SessionSize (1,1) double = -1
        NumWorkersBusy (1,1) double = 0
        SessionIdleAt (1,1) datetime = NaT
        IdleShutdownTimeout (1,1) duration = seconds(NaN)
        Error (1,1) string = ""
        StartTime datetime = datetime.empty()
        FinishTime datetime = datetime.empty()
        RestartOnClusterChange (1,1) logical = false
        RestartOnPreferredNumWorkersChange (1,1) logical = false
        RemainingSecondsBeforeShutdown (1,1) int64 = NaN
    end
    
    methods
        function obj = SessionInfo(propArgs)
            arguments
                propArgs.?parallel.internal.pool.SessionInfo
            end
            propCell = namedargs2cell(propArgs);
            for idx = 1:2:numel(propCell)
                [p,v] = deal(propCell{idx:idx+1});
                obj.(p) = v;
            end
        end
    end
end
