private IEnumerable<Event> Customer(Environment env, string name, Resource counter, TimeSpan meanTimeInBank)
        {
            var arrive = env.Now;

              env.Log("{0} {1}: Here I am", arrive, name);

              using (var req = counter.Request()) {
            // Wait for the counter or abort at the end of our tether
            var timeout = env.TimeoutUniform(MinPatience, MaxPatience);
            yield return req | timeout;

            var wait = env.Now - arrive;

            if (req.IsProcessed) {
              // We got the counter
              env.Log("{0} {1}: waited {2}", env.Now, name, wait);

              yield return env.TimeoutExponential(meanTimeInBank);
              env.Log("{0} {1}: Finished", env.Now, name);
            } else {
              // We reneged
              env.Log("{0} {1}: RENEGED after {2}", env.Now, name, wait);
            }
              }
        }
示例#2
0
 static IEnumerable<Event> Benchmark1Proc(Environment env, int n)
 {
     while (true) {
     yield return env.TimeoutUniform(TimeSpan.Zero, TimeSpan.FromSeconds(2 * n));
     perf++;
       }
 }