DynamoDS/Dynamo — pull request #3193 by Benglin (2014-11-19 16:59:43+00:00)
Title: DNM: Execution interval implementation

Background
-----
This pull request addresses [an internally track task](http://adsk-oss.myjetbrains.com/youtrack/issue/MAGN-4444) by reimplementing evaluation interval support without ```DynamoRunner``` (which was disabled and replaced by ```DynamoScheduler```).

Changes
-----

1. ```PulseMaker``` class is introduced to manage an internal timer, as well as states for evaluation requests.

2. ```DynamoModel``` now owns an internal instance of ```PulseMaker```.

3. The following new APIs on ```DynamoModel``` are introduced:

- ```DynamoModel.StartPeriodicEvaluation(int milliseconds)```
- ```DynamoModel.StopPeriodicEvaluation(void)```

4. Temporary introduce a new ```Set Timer``` button on Dynamo UI, which sets a hard-coded timing value of ```100ms```.

Testing
-----
The following test data is gathered with the current hard-coded interval value of ```100ms```:

- ```OnTimerTicked``` is the time when timer ticks (every ```100ms``` right now).
- ```BeginRunExpression``` is the call to ```DynamoModel.RunExpression```.
- ```OnRunExpressionCompleted``` is the notification received when an evaluation completes.

If everything goes uninterrupted, the cycle should go ```OnTimerTicked > BeginRunExpression > OnRunExpressionCompleted```.

OnTimerTicked
BeginRunExpression
OnRunExpressionCompleted
OnTimerTicked
BeginRunExpression
OnRunExpressionCompleted
OnTimerTicked
BeginRunExpression ------------ (1)
OnTimerTicked ----------------- (2)
OnTimerTicked
OnTimerTicked
OnTimerTicked
OnTimerTicked ----------------- (3)
OnRunExpressionCompleted ------ (4)
BeginRunExpression ------------ (5)
OnRunExpressionCompleted
OnTimerTicked ----------------- (6)
BeginRunExpression
OnRunExpressionCompleted

Interesting facts:

1. We should have seen ```OnRunExpressionCompleted``` after ```BeginRunExpression(1)``` but it did not complete on time. That allows space for multiple ```OnTimerTicked``` events to occur (```OnTimerTicked(2, 3)```).

2. The excessive ```OnTimerTicked``` events marked ```PulseMaker.evaluationRequestPending = true```, marking an outstanding evaluation needed.

3. ```OnRunExpressionCompleted(4)``` arrives, immediately triggering ```BeginRunExpression(5)``` without any ```OnTimerTicked``` event (due to ```evaluationRequestPending == true```).

4. Subsequent ```OnTimerTicked(6)``` resumes a normal cycle of ```OnTimerTicked > BeginRunExpression > OnRunExpressionCompleted```.