-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
1,717 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
using Microsoft.Coyote.Runtime; | ||
using SystemAutoResetEvent = System.Threading.AutoResetEvent; | ||
using SystemEventResetMode = System.Threading.EventResetMode; | ||
using SystemWaitHandle = System.Threading.WaitHandle; | ||
|
||
namespace Microsoft.Coyote.Rewriting.Types.Threading | ||
{ | ||
/// <summary> | ||
/// Represents a thread synchronization event that, when signaled, resets automatically | ||
/// after releasing a single waiting thread. | ||
/// </summary> | ||
/// <remarks>This type is intended for compiler use rather than use directly in code.</remarks> | ||
[System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)] | ||
public static class AutoResetEvent | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="AutoResetEvent"/> class, with a value | ||
/// indicating whether to set the initial state to signaled. | ||
/// </summary> | ||
public static SystemAutoResetEvent Create(bool initialState) | ||
{ | ||
var instance = new SystemAutoResetEvent(initialState); | ||
var runtime = CoyoteRuntime.Current; | ||
if (runtime.SchedulingPolicy is SchedulingPolicy.Interleaving) | ||
{ | ||
Resource resource = new Resource(runtime, instance, initialState); | ||
Resource.Add(resource); | ||
} | ||
|
||
return instance; | ||
} | ||
|
||
/// <summary> | ||
/// Resource that is used to control a <see cref="SystemAutoResetEvent"/> during testing. | ||
/// </summary> | ||
internal class Resource : EventWaitHandle.Resource | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="Resource"/> class. | ||
/// </summary> | ||
internal Resource(CoyoteRuntime runtime, SystemWaitHandle handle, bool initialState) | ||
: base(runtime, handle, initialState, SystemEventResetMode.AutoReset) | ||
{ | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.