Skip to content

Commit 5fd3409

Browse files
committed
Rename conflicting property and enable setting in case ownership of the request changes (Closes #13)
1 parent df00cd1 commit 5fd3409

File tree

6 files changed

+11
-11
lines changed

6 files changed

+11
-11
lines changed

SimSharp/Core/Resources/Events/ContainerGet.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ namespace SimSharp {
2222
public class ContainerGet : Event {
2323
public double Amount { get; protected set; }
2424
public DateTime Time { get; private set; }
25-
public Process Process { get; private set; }
25+
public Process Owner { get; set; }
2626

2727
public ContainerGet(Simulation environment, Action<Event> callback, double amount)
2828
: base(environment) {
2929
if (amount <= 0) throw new ArgumentException("Amount must be > 0.", "amount");
3030
Amount = amount;
3131
CallbackList.Add(callback);
3232
Time = environment.Now;
33-
Process = environment.ActiveProcess;
33+
Owner = environment.ActiveProcess;
3434
}
3535
}
3636
}

SimSharp/Core/Resources/Events/ContainerPut.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ namespace SimSharp {
2222
public class ContainerPut : Event {
2323
public double Amount { get; protected set; }
2424
public DateTime Time { get; private set; }
25-
public Process Process { get; private set; }
25+
public Process Owner { get; set; }
2626

2727
public ContainerPut(Simulation environment, Action<Event> callback, double amount)
2828
: base(environment) {
2929
if (amount <= 0) throw new ArgumentException("Amount must be > 0.", "amount");
3030
Amount = amount;
3131
CallbackList.Add(callback);
3232
Time = environment.Now;
33-
Process = environment.ActiveProcess;
33+
Owner = environment.ActiveProcess;
3434
}
3535
}
3636
}

SimSharp/Core/Resources/Events/Request.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ namespace SimSharp {
2222
public class Request : Event, IDisposable {
2323
private readonly Action<Event> disposeCallback;
2424
public DateTime Time { get; private set; }
25-
public Process Process { get; private set; }
25+
public Process Owner { get; set; }
2626

2727
public Request(Simulation environment, Action<Event> callback, Action<Event> disposeCallback)
2828
: base(environment) {
2929
CallbackList.Add(callback);
3030
this.disposeCallback = disposeCallback;
3131
Time = environment.Now;
32-
Process = environment.ActiveProcess;
32+
Owner = environment.ActiveProcess;
3333
}
3434

3535
public virtual void Dispose() {

SimSharp/Core/Resources/Events/StoreGet.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ You should have received a copy of the GNU General Public License
2121
namespace SimSharp {
2222
public class StoreGet : Event {
2323
public DateTime Time { get; private set; }
24-
public Process Process { get; private set; }
24+
public Process Owner { get; set; }
2525

2626
public StoreGet(Simulation environment, Action<Event> callback)
2727
: base(environment) {
2828
CallbackList.Add(callback);
2929
Time = environment.Now;
30-
Process = environment.ActiveProcess;
30+
Owner = environment.ActiveProcess;
3131
}
3232
}
3333
}

SimSharp/Core/Resources/Events/StorePut.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ You should have received a copy of the GNU General Public License
2121
namespace SimSharp {
2222
public class StorePut : Event {
2323
public DateTime Time { get; private set; }
24-
public Process Process { get; private set; }
24+
public Process Owner { get; set; }
2525

2626
public StorePut(Simulation environment, Action<Event> callback, object value)
2727
: base(environment) {
2828
if (value == null) throw new ArgumentNullException("value", "Value to put in a Store cannot be null.");
2929
CallbackList.Add(callback);
3030
Value = value;
3131
Time = environment.Now;
32-
Process = environment.ActiveProcess;
32+
Owner = environment.ActiveProcess;
3333
}
3434
}
3535
}

SimSharp/Core/Resources/PreemptiveResource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ protected virtual void DoRequest(PreemptiveRequest request) {
118118
var preempt = Users.MaxItems(x => x).Last();
119119
if (preempt.CompareTo(request) > 0) {
120120
Users.Remove(preempt);
121-
preempt.Process.Interrupt(new Preempted(request.Process, preempt.Time));
121+
preempt.Owner?.Interrupt(new Preempted(request.Owner, preempt.Time));
122122
}
123123
}
124124
if (Users.Count < Capacity) {

0 commit comments

Comments
 (0)