Skip to content
This repository was archived by the owner on Aug 26, 2022. It is now read-only.

Commit a093861

Browse files
authored
Exposed new send event APIs that receive an operation group id (#433)
1 parent eeb6f2f commit a093861

File tree

29 files changed

+485
-505
lines changed

29 files changed

+485
-505
lines changed

Common/version.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!-- This file may be overwritten by automation. Only values allowed here are VersionPrefix and VersionSuffix. -->
22
<Project>
33
<PropertyGroup>
4-
<VersionPrefix>1.6.0</VersionPrefix>
4+
<VersionPrefix>1.6.1</VersionPrefix>
55
<VersionSuffix></VersionSuffix>
66
</PropertyGroup>
77
</Project>

Samples/Framework/build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
<OutputPath>..\bin\</OutputPath>
1313
</PropertyGroup>
1414
<ItemGroup>
15-
<PackageReference Include="Microsoft.PSharp" Version="1.6.0" />
15+
<PackageReference Include="Microsoft.PSharp" Version="1.6.1" />
1616
</ItemGroup>
1717
</Project>

Samples/Language/build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@
1010
<OutputPath>..\bin\</OutputPath>
1111
</PropertyGroup>
1212
<ItemGroup>
13-
<PackageReference Include="Microsoft.PSharp" Version="1.6.0" />
13+
<PackageReference Include="Microsoft.PSharp" Version="1.6.1" />
1414
</ItemGroup>
1515
</Project>

Scripts/NuGet/PSharp.nuspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<package >
33
<metadata>
44
<id>Microsoft.PSharp</id>
5-
<version>1.6.0</version>
5+
<version>1.6.1</version>
66
<authors>Microsoft</authors>
77
<projectUrl>https://github.com/p-org/PSharp</projectUrl>
88
<license type="expression">MIT</license>
99
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1010
<description>P# is a framework for rapid development of reliable asynchronous software.</description>
11-
<releaseNotes>This release contains the 1.6.0 version of the P# framework.</releaseNotes>
11+
<releaseNotes>This release contains the 1.6.1 version of the P# framework.</releaseNotes>
1212
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
1313
<tags>asynchrony reliability specifications reactive state-machines testing</tags>
1414
</metadata>

Source/Core/IMachineRuntime.cs

Lines changed: 36 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public interface IMachineRuntime : IDisposable
3939
/// </summary>
4040
/// <param name="type">Type of the machine.</param>
4141
/// <param name="machineName">Optional machine name used for logging.</param>
42-
/// <returns>The result is the <see cref="MachineId"/>.</returns>
42+
/// <returns>The result is the machine id.</returns>
4343
MachineId CreateMachineId(Type type, string machineName = null);
4444

4545
/// <summary>
@@ -50,7 +50,7 @@ public interface IMachineRuntime : IDisposable
5050
/// </summary>
5151
/// <param name="type">Type of the machine.</param>
5252
/// <param name="machineName">Unique name used to create or get the machine id.</param>
53-
/// <returns>The result is the <see cref="MachineId"/>.</returns>
53+
/// <returns>The result is the machine id.</returns>
5454
MachineId CreateMachineIdFromName(Type type, string machineName);
5555

5656
/// <summary>
@@ -61,8 +61,8 @@ public interface IMachineRuntime : IDisposable
6161
/// <param name="type">Type of the machine.</param>
6262
/// <param name="e">Optional event used during initialization.</param>
6363
/// <param name="operationGroupId">Optional operation group id.</param>
64-
/// <returns>The result is the <see cref="MachineId"/>.</returns>
65-
MachineId CreateMachine(Type type, Event e = null, Guid? operationGroupId = null);
64+
/// <returns>The result is the machine id.</returns>
65+
MachineId CreateMachine(Type type, Event e = null, Guid operationGroupId = default);
6666

6767
/// <summary>
6868
/// Creates a new machine of the specified <see cref="Type"/> and name, and
@@ -73,8 +73,8 @@ public interface IMachineRuntime : IDisposable
7373
/// <param name="machineName">Optional machine name used for logging.</param>
7474
/// <param name="e">Optional event used during initialization.</param>
7575
/// <param name="operationGroupId">Optional operation group id.</param>
76-
/// <returns>The result is the <see cref="MachineId"/>.</returns>
77-
MachineId CreateMachine(Type type, string machineName, Event e = null, Guid? operationGroupId = null);
76+
/// <returns>The result is the machine id.</returns>
77+
MachineId CreateMachine(Type type, string machineName, Event e = null, Guid operationGroupId = default);
7878

7979
/// <summary>
8080
/// Creates a new machine of the specified type, using the specified <see cref="MachineId"/>.
@@ -85,8 +85,8 @@ public interface IMachineRuntime : IDisposable
8585
/// <param name="type">Type of the machine.</param>
8686
/// <param name="e">Optional event used during initialization.</param>
8787
/// <param name="operationGroupId">Optional operation group id.</param>
88-
/// <returns>The result is the <see cref="MachineId"/>.</returns>
89-
MachineId CreateMachine(MachineId mid, Type type, Event e = null, Guid? operationGroupId = null);
88+
/// <returns>The result is the machine id.</returns>
89+
MachineId CreateMachine(MachineId mid, Type type, Event e = null, Guid operationGroupId = default);
9090

9191
/// <summary>
9292
/// Creates a new machine of the specified <see cref="Type"/> and with the
@@ -97,8 +97,8 @@ public interface IMachineRuntime : IDisposable
9797
/// <param name="type">Type of the machine.</param>
9898
/// <param name="e">Optional event used during initialization.</param>
9999
/// <param name="operationGroupId">Optional operation group id.</param>
100-
/// <returns>Task that represents the asynchronous operation. The task result is the <see cref="MachineId"/>.</returns>
101-
Task<MachineId> CreateMachineAndExecuteAsync(Type type, Event e = null, Guid? operationGroupId = null);
100+
/// <returns>Task that represents the asynchronous operation. The task result is the machine id.</returns>
101+
Task<MachineId> CreateMachineAndExecuteAsync(Type type, Event e = null, Guid operationGroupId = default);
102102

103103
/// <summary>
104104
/// Creates a new machine of the specified <see cref="Type"/> and name, and with
@@ -110,8 +110,8 @@ public interface IMachineRuntime : IDisposable
110110
/// <param name="machineName">Optional machine name used for logging.</param>
111111
/// <param name="e">Optional event used during initialization.</param>
112112
/// <param name="operationGroupId">Optional operation group id.</param>
113-
/// <returns>Task that represents the asynchronous operation. The task result is the <see cref="MachineId"/>.</returns>
114-
Task<MachineId> CreateMachineAndExecuteAsync(Type type, string machineName, Event e = null, Guid? operationGroupId = null);
113+
/// <returns>Task that represents the asynchronous operation. The task result is the machine id.</returns>
114+
Task<MachineId> CreateMachineAndExecuteAsync(Type type, string machineName, Event e = null, Guid operationGroupId = default);
115115

116116
/// <summary>
117117
/// Creates a new machine of the specified <see cref="Type"/>, using the specified
@@ -124,8 +124,8 @@ public interface IMachineRuntime : IDisposable
124124
/// <param name="type">Type of the machine.</param>
125125
/// <param name="e">Optional event used during initialization.</param>
126126
/// <param name="operationGroupId">Optional operation group id.</param>
127-
/// <returns>Task that represents the asynchronous operation. The task result is the <see cref="MachineId"/>.</returns>
128-
Task<MachineId> CreateMachineAndExecuteAsync(MachineId mid, Type type, Event e = null, Guid? operationGroupId = null);
127+
/// <returns>Task that represents the asynchronous operation. The task result is the machine id.</returns>
128+
Task<MachineId> CreateMachineAndExecuteAsync(MachineId mid, Type type, Event e = null, Guid operationGroupId = default);
129129

130130
/// <summary>
131131
/// Creates a new machine of the specified <see cref="Type"/> and with the
@@ -136,9 +136,9 @@ public interface IMachineRuntime : IDisposable
136136
/// <param name="type">Type of the machine.</param>
137137
/// <param name="e">Optional event used during initialization.</param>
138138
/// <param name="operationGroupId">Optional operation group id.</param>
139-
/// <returns>Task that represents the asynchronous operation. The task result is the <see cref="MachineId"/>.</returns>
139+
/// <returns>Task that represents the asynchronous operation. The task result is the machine id.</returns>
140140
[Obsolete("Please use IMachineRuntime.CreateMachineAndExecuteAsync(...) instead.")]
141-
Task<MachineId> CreateMachineAndExecute(Type type, Event e = null, Guid? operationGroupId = null);
141+
Task<MachineId> CreateMachineAndExecute(Type type, Event e = null, Guid operationGroupId = default);
142142

143143
/// <summary>
144144
/// Creates a new machine of the specified <see cref="Type"/> and name, and with
@@ -150,9 +150,9 @@ public interface IMachineRuntime : IDisposable
150150
/// <param name="machineName">Optional machine name used for logging.</param>
151151
/// <param name="e">Optional event used during initialization.</param>
152152
/// <param name="operationGroupId">Optional operation group id.</param>
153-
/// <returns>Task that represents the asynchronous operation. The task result is the <see cref="MachineId"/>.</returns>
153+
/// <returns>Task that represents the asynchronous operation. The task result is the machine id.</returns>
154154
[Obsolete("Please use IMachineRuntime.CreateMachineAndExecuteAsync(...) instead.")]
155-
Task<MachineId> CreateMachineAndExecute(Type type, string machineName, Event e = null, Guid? operationGroupId = null);
155+
Task<MachineId> CreateMachineAndExecute(Type type, string machineName, Event e = null, Guid operationGroupId = default);
156156

157157
/// <summary>
158158
/// Creates a new machine of the specified <see cref="Type"/>, using the specified
@@ -165,40 +165,43 @@ public interface IMachineRuntime : IDisposable
165165
/// <param name="type">Type of the machine.</param>
166166
/// <param name="e">Optional event used during initialization.</param>
167167
/// <param name="operationGroupId">Optional operation group id.</param>
168-
/// <returns>Task that represents the asynchronous operation. The task result is the <see cref="MachineId"/>.</returns>
168+
/// <returns>Task that represents the asynchronous operation. The task result is the machine id.</returns>
169169
[Obsolete("Please use IMachineRuntime.CreateMachineAndExecuteAsync(...) instead.")]
170-
Task<MachineId> CreateMachineAndExecute(MachineId mid, Type type, Event e = null, Guid? operationGroupId = null);
170+
Task<MachineId> CreateMachineAndExecute(MachineId mid, Type type, Event e = null, Guid operationGroupId = default);
171171

172172
/// <summary>
173173
/// Sends an asynchronous <see cref="Event"/> to a machine.
174174
/// </summary>
175175
/// <param name="target">The id of the target machine.</param>
176176
/// <param name="e">The event to send.</param>
177-
/// <param name="options">Optional parameters of a send operation.</param>
178-
void SendEvent(MachineId target, Event e, SendOptions options = null);
177+
/// <param name="operationGroupId">Optional operation group id.</param>
178+
/// <param name="options">Optional configuration of a send operation.</param>
179+
void SendEvent(MachineId target, Event e, Guid operationGroupId = default, SendOptions options = null);
179180

180181
/// <summary>
181182
/// Sends an <see cref="Event"/> to a machine. Returns immediately if the target machine was already
182-
/// running. Otherwise blocks until the machine handles the event and reaches quiescense again.
183+
/// running. Otherwise blocks until the machine handles the event and reaches quiescense.
183184
/// </summary>
184185
/// <param name="target">The id of the target machine.</param>
185186
/// <param name="e">The event to send.</param>
186-
/// <param name="options">Optional parameters of a send operation.</param>
187+
/// <param name="operationGroupId">Optional operation group id.</param>
188+
/// <param name="options">Optional configuration of a send operation.</param>
187189
/// <returns>Task that represents the asynchronous operation. The task result is true if
188190
/// the event was handled, false if the event was only enqueued.</returns>
189-
Task<bool> SendEventAndExecuteAsync(MachineId target, Event e, SendOptions options = null);
191+
Task<bool> SendEventAndExecuteAsync(MachineId target, Event e, Guid operationGroupId = default, SendOptions options = null);
190192

191193
/// <summary>
192194
/// Sends an <see cref="Event"/> to a machine. Returns immediately if the target machine was already
193-
/// running. Otherwise blocks until the machine handles the event and reaches quiescense again.
195+
/// running. Otherwise blocks until the machine handles the event and reaches quiescense.
194196
/// </summary>
195197
/// <param name="target">The id of the target machine.</param>
196198
/// <param name="e">The event to send.</param>
197-
/// <param name="options">Optional parameters of a send operation.</param>
199+
/// <param name="operationGroupId">Optional operation group id.</param>
200+
/// <param name="options">Optional configuration of a send operation.</param>
198201
/// <returns>Task that represents the asynchronous operation. The task result is true if
199202
/// the event was handled, false if the event was only enqueued.</returns>
200203
[Obsolete("Please use IMachineRuntime.SendEventAndExecuteAsync(...) instead.")]
201-
Task<bool> SendEventAndExecute(MachineId target, Event e, SendOptions options = null);
204+
Task<bool> SendEventAndExecute(MachineId target, Event e, Guid operationGroupId = default, SendOptions options = null);
202205

203206
/// <summary>
204207
/// Registers a new specification monitor of the specified <see cref="Type"/>.
@@ -313,5 +316,10 @@ bool FairRandom(
313316
/// </summary>
314317
/// <param name="logger">The logger to install.</param>
315318
void SetLogger(ILogger logger);
319+
320+
/// <summary>
321+
/// Terminates the runtime and notifies each active machine to halt execution.
322+
/// </summary>
323+
void Stop();
316324
}
317325
}

Source/Core/IO/Logging/DisposingLogger.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,10 @@ public void OnWait(MachineId machineId, string currStateName, params Type[] even
207207
/// <param name="senderId">The machine that sent the event, if any.</param>
208208
/// <param name="senderStateName">The name of the current state of the sender machine, if any.</param>
209209
/// <param name="eventName">The event being sent.</param>
210-
/// <param name="operationGroupId">The operation group id, if any.</param>
210+
/// <param name="operationGroupId">The operation group id.</param>
211211
/// <param name="isTargetHalted">Is the target machine halted.</param>
212-
public void OnSend(MachineId targetMachineId, MachineId senderId, string senderStateName, string eventName, Guid? operationGroupId, bool isTargetHalted)
212+
public void OnSend(MachineId targetMachineId, MachineId senderId, string senderStateName, string eventName,
213+
Guid operationGroupId, bool isTargetHalted)
213214
{
214215
}
215216

Source/Core/IO/Logging/ILogger.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ public interface ILogger : IDisposable
163163
/// <param name="senderId">The id of the machine that sent the event, if any.</param>
164164
/// <param name="senderStateName">The name of the current state of the sender machine, if any.</param>
165165
/// <param name="eventName">The event being sent.</param>
166-
/// <param name="operationGroupId">The operation group id, if any.</param>
166+
/// <param name="operationGroupId">The operation group id.</param>
167167
/// <param name="isTargetHalted">Is the target machine halted.</param>
168-
void OnSend(MachineId targetMachineId, MachineId senderId, string senderStateName,
169-
string eventName, Guid? operationGroupId, bool isTargetHalted);
168+
void OnSend(MachineId targetMachineId, MachineId senderId, string senderStateName, string eventName,
169+
Guid operationGroupId, bool isTargetHalted);
170170

171171
/// <summary>
172172
/// Called when a machine has been created.

Source/Core/IO/Logging/MachineLogger.cs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,10 @@ public virtual string FormatOnWaitString(MachineId machineId, string currStateNa
379379
/// <param name="senderId">The id of the machine that sent the event, if any.</param>
380380
/// <param name="senderStateName">The name of the current state of the sender machine, if any.</param>
381381
/// <param name="eventName">The event being sent.</param>
382-
/// <param name="operationGroupId">The operation group id, if any.</param>
382+
/// <param name="operationGroupId">The operation group id.</param>
383383
/// <param name="isTargetHalted">Is the target machine halted.</param>
384-
public virtual void OnSend(MachineId targetMachineId, MachineId senderId, string senderStateName,
385-
string eventName, Guid? operationGroupId, bool isTargetHalted)
384+
public virtual void OnSend(MachineId targetMachineId, MachineId senderId, string senderStateName, string eventName,
385+
Guid operationGroupId, bool isTargetHalted)
386386
{
387387
if (this.IsVerbose)
388388
{
@@ -397,20 +397,15 @@ public virtual void OnSend(MachineId targetMachineId, MachineId senderId, string
397397
/// <param name="senderId">The id of the machine that sent the event, if any.</param>
398398
/// <param name="senderStateName">The name of the current state of the sender machine, if any.</param>
399399
/// <param name="eventName">The event being sent.</param>
400-
/// <param name="operationGroupId">The operation group id, if any.</param>
400+
/// <param name="operationGroupId">The operation group id.</param>
401401
/// <param name="isTargetHalted">Is the target machine halted.</param>
402402
public virtual string FormatOnSendString(MachineId targetMachineId, MachineId senderId, string senderStateName, string eventName,
403-
Guid? operationGroupId, bool isTargetHalted)
404-
{
405-
var guid = (operationGroupId.HasValue && operationGroupId.Value != Guid.Empty) ?
406-
operationGroupId.Value.ToString() : "<none>";
407-
var target = isTargetHalted
408-
? $"a halted machine '{targetMachineId}'"
409-
: $"machine '{targetMachineId}'";
410-
var sender = senderId != null
411-
? $"Machine '{senderId}' in state '{senderStateName}'"
412-
: $"The runtime";
413-
return $"<SendLog> Operation Group {guid}: {sender} sent event '{eventName}' to {target}.";
403+
Guid operationGroupId, bool isTargetHalted)
404+
{
405+
var operationGroupIdMsg = operationGroupId != Guid.Empty ? $" (operation group '{operationGroupId}')" : string.Empty;
406+
var target = isTargetHalted ? $"halted machine '{targetMachineId}'" : $"machine '{targetMachineId}'";
407+
var sender = senderId != null ? $"Machine '{senderId}' in state '{senderStateName}'" : $"The runtime";
408+
return $"<SendLog> {sender} sent event '{eventName}' to {target}{operationGroupIdMsg}.";
414409
}
415410

416411
/// <summary>

0 commit comments

Comments
 (0)