Subversion Repositories programming

Rev

Rev 335 | Rev 338 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 335 Rev 337
Line 94... Line 94...
94
 * You must pass the object in, since this is a static function
94
 * You must pass the object in, since this is a static function
95
 * and we aren't allowed to access the this pointer.
95
 * and we aren't allowed to access the this pointer.
96
 */
96
 */
97
void Elevator::thread_entry (const Elevator *me)
97
void Elevator::thread_entry (const Elevator *me)
98
{
98
{
-
 
99
    assert (me != NULL);
-
 
100
 
99
    Elevator *pthis = (Elevator*)me;
101
    Elevator *pthis = (Elevator*)me;
100
 
102
 
101
    while (!pthis->terminate)
103
    while (!pthis->terminate)
102
    {
104
    {
103
        /* Implement "pausing" */
105
        /* Implement "pausing" */
Line 262... Line 264...
262
    return false;
264
    return false;
263
}
265
}
264
 
266
 
265
bool Elevator::near_floor (int floor)
267
bool Elevator::near_floor (int floor)
266
{
268
{
-
 
269
    assert (floor >= 0);
-
 
270
    assert (floor < num_floors);
-
 
271
 
267
    const float thresh  = ELEVATOR_TIME_MOVE_AMOUNT / 2.0;
272
    const float thresh  = ELEVATOR_TIME_MOVE_AMOUNT / 2.0;
268
    const float greater = floor + thresh;
273
    const float greater = floor + thresh;
269
    const float lower   = floor - thresh;
274
    const float lower   = floor - thresh;
270
 
275
 
271
    if (current_floor > lower && current_floor < greater)
276
    if (current_floor > lower && current_floor < greater)