| 58 | } |
| 59 | |
| 60 | unsigned int CallGenerationTask::wake() |
| 61 | { |
| 62 | int retval; |
| 63 | if (paused || (users >= 0)) { |
| 64 | // When paused or when we're doing user-based rather than |
| 65 | // rate-based calls, return a sentinel value to indicate that |
| 66 | // this task should wait forever before rescheduling. |
| 67 | retval = DONT_RESCHEDULE; |
| 68 | } else { |
| 69 | float ms_per_call = rate_period_ms/MAX(rate, 1); |
| 70 | /* We need to compute when the next call is going to be |
| 71 | * opened. The current time is the time when the rate last |
| 72 | * changed, plus the number of calls since then multiplied by |
| 73 | * the number of milliseconds between each call. |
| 74 | * |
| 75 | * We then add the number of milliseconds between each call to that |
| 76 | * figure. */ |
| 77 | |
| 78 | retval = (unsigned long) last_rate_change_time + |
| 79 | (calls_since_last_rate_change * ms_per_call) + ms_per_call; |
| 80 | |
| 81 | /* On startup, when last_rate_change_time is 0, this |
| 82 | calculation can be 0 (if we're opening multiple calls per ms). |
| 83 | But 0 indicates that we should wait forever, so avoid that and |
| 84 | return 1 instead. */ |
| 85 | if (retval == 0 /* DONT_RESCHEDULE */) { |
| 86 | retval = 1; |
| 87 | } |
| 88 | } |
| 89 | return retval; |
| 90 | } |
| 91 | |
| 92 | bool CallGenerationTask::run() |
| 93 | { |
nothing calls this directly
no outgoing calls
no test coverage detected