127 lines
3.6 KiB
Plaintext
127 lines
3.6 KiB
Plaintext
|
///////////////////////////////////////////////////////////////////////////////
|
||
|
//
|
||
|
// Microsoft Research Singularity
|
||
|
//
|
||
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
||
|
//
|
||
|
// File: Contracts\ServiceManager.Contracts\ServiceManagementContracts.sg
|
||
|
//
|
||
|
// Note: SMS-clients contract
|
||
|
//
|
||
|
using Microsoft.SingSharp;
|
||
|
using Microsoft.Singularity.Channels;
|
||
|
using Microsoft.Singularity.Directory;
|
||
|
|
||
|
namespace Microsoft.Singularity.ServiceManager
|
||
|
{
|
||
|
public rep struct ServiceInfo : ITracked
|
||
|
{
|
||
|
private char[]! in ExHeap name;
|
||
|
private char[]! in ExHeap binary;
|
||
|
public int Id;
|
||
|
public ServiceType Type;
|
||
|
|
||
|
public ServiceInfo(int id, string! name, string! binary,
|
||
|
ServiceType type)
|
||
|
{
|
||
|
Id = id;
|
||
|
this.name = Bitter.FromString2(name);
|
||
|
this.binary = Bitter.FromString2(binary);
|
||
|
this.Type = type;
|
||
|
}
|
||
|
|
||
|
public string! Name
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
expose (this) {
|
||
|
return Bitter.ToString2(name);
|
||
|
}
|
||
|
}
|
||
|
private set {}
|
||
|
}
|
||
|
|
||
|
public string! Binary
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
expose (this) {
|
||
|
return Bitter.ToString2(binary);
|
||
|
}
|
||
|
}
|
||
|
private set {}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public enum ServiceType : uint
|
||
|
{
|
||
|
Unknown,
|
||
|
Default,
|
||
|
Resilient,
|
||
|
}
|
||
|
|
||
|
public contract ServiceManagementContract : ServiceContract
|
||
|
{
|
||
|
public const string ModuleName = "/services";
|
||
|
|
||
|
out message Success();
|
||
|
|
||
|
out message NotFound(ServiceControlContract.Exp:Start! ep);
|
||
|
out message PermissionDenied(ServiceControlContract.Exp:Start! ep);
|
||
|
out message TryAgain(ServiceControlContract.Exp:Start! ep);
|
||
|
|
||
|
in message Bind(ServiceInfo*! in ExHeap info, ServiceControlContract.Exp:Start! ep);
|
||
|
out message AckBind();
|
||
|
|
||
|
in message GetControl(int id, ServiceControlContract.Exp:Start! ep);
|
||
|
out message AckGetControl();
|
||
|
|
||
|
in message Unbind(int id);
|
||
|
out message AckUnbind(ServiceControlContract.Exp:Start! ep);
|
||
|
out message ControlNotFound();
|
||
|
out message ServiceNotFound();
|
||
|
out message ControlPermissionDenied();
|
||
|
|
||
|
in message BeginEnumeration();
|
||
|
in message MoveNext();
|
||
|
in message EndEnumeration();
|
||
|
out message EnumerationTerminated();
|
||
|
out message Current(ServiceInfo*! in ExHeap info);
|
||
|
|
||
|
override state Start : one {
|
||
|
Success! -> Ready;
|
||
|
}
|
||
|
|
||
|
state Enumerate : one {
|
||
|
EnumerationTerminated! -> Ready;
|
||
|
Current! -> EnumerateAck;
|
||
|
}
|
||
|
|
||
|
state EnumerateAck : one {
|
||
|
MoveNext? -> Enumerate;
|
||
|
EndEnumeration? -> Ready;
|
||
|
}
|
||
|
|
||
|
state Ready : one {
|
||
|
Bind? -> (AckBind!
|
||
|
or NotFound!
|
||
|
or PermissionDenied!
|
||
|
) -> Ready;
|
||
|
|
||
|
GetControl? -> (AckGetControl!
|
||
|
or NotFound!
|
||
|
or PermissionDenied!
|
||
|
or TryAgain!
|
||
|
) -> Ready;
|
||
|
|
||
|
Unbind? -> (AckUnbind!
|
||
|
or ControlNotFound!
|
||
|
or ServiceNotFound!
|
||
|
or ControlPermissionDenied!
|
||
|
) -> Ready;
|
||
|
|
||
|
BeginEnumeration? -> Enumerate;
|
||
|
}
|
||
|
}
|
||
|
}
|