Skip to main content
added 153 characters in body
Source Link
lennon310
  • 3.2k
  • 7
  • 18
  • 34

It's valid but problematic for debugging, performance and reading clarity.

Can you use

void updateState() {

    // do some stuff before

    while (this.timeReference.isAfter(lastInterval.getBeggining()) 
    {
        this.timeReference = lastInterval.getEnd();
        lastInterval = intervalIterator.next();
    }

    // do more stuff after

}

instead if maybeUpdateTime() is only called by updateState()? If it's called by other functions, the condition in while could be wrapped to maybeUpdateTime() and inside the loop it is wrapped to updateTime().

Or if you have performance requirements and don't want to (1) consume more CPU resources, (2) block other tasks in the same thread, maybe consider put maybeUpdateTime() into a separate thread that allows you to wait for a task to complete (update time).

It's valid but problematic for debugging, performance and reading clarity.

Can you use

void updateState() {

    // do some stuff before

    while (this.timeReference.isAfter(lastInterval.getBeggining()) 
    {
        this.timeReference = lastInterval.getEnd();
        lastInterval = intervalIterator.next();
    }

    // do more stuff after

}

instead if maybeUpdateTime() is only called by updateState()?

Or if you have performance requirements and don't want to (1) consume more CPU resources, (2) block other tasks in the same thread, maybe consider put maybeUpdateTime() into a separate thread that allows you to wait for a task to complete (update time).

It's valid but problematic for debugging, performance and reading clarity.

Can you use

void updateState() {

    // do some stuff before

    while (this.timeReference.isAfter(lastInterval.getBeggining()) 
    {
        this.timeReference = lastInterval.getEnd();
        lastInterval = intervalIterator.next();
    }

    // do more stuff after

}

instead if maybeUpdateTime() is only called by updateState()? If it's called by other functions, the condition in while could be wrapped to maybeUpdateTime() and inside the loop it is wrapped to updateTime().

Or if you have performance requirements and don't want to (1) consume more CPU resources, (2) block other tasks in the same thread, maybe consider put maybeUpdateTime() into a separate thread that allows you to wait for a task to complete (update time).

deleted 2 characters in body
Source Link
lennon310
  • 3.2k
  • 7
  • 18
  • 34

It's valid but problematic for debugging, performance and reading clarity.

Can you use

void updateState() {

    // do some stuff before

    while (this.timeReference.isAfter(lastInterval.getBeggining()) 
    {
        this.timeReference = lastInterval.getEnd();
        lastInterval = intervalIterator.next();
    }

    // do more stuff after

}

instead if maybeUpdateTime() is only called by updateState()?

Or if you have performance requirements and don't want to (1) consume more CPU resources, or   (2) block other tasks in the same thread, maybe consider put maybeUpdateTime() into a separate thread that allows you to wait for a task to complete (update time).

It's valid but problematic for debugging, performance and reading clarity.

Can you use

void updateState() {

    // do some stuff before

    while (this.timeReference.isAfter(lastInterval.getBeggining()) 
    {
        this.timeReference = lastInterval.getEnd();
        lastInterval = intervalIterator.next();
    }

    // do more stuff after

}

instead if maybeUpdateTime() is only called by updateState()?

Or if you have performance requirements and don't want to (1) consume more CPU resources, or (2) block other tasks in the same thread, maybe consider put maybeUpdateTime() into a separate thread that allows you to wait for a task to complete (update time).

It's valid but problematic for debugging, performance and reading clarity.

Can you use

void updateState() {

    // do some stuff before

    while (this.timeReference.isAfter(lastInterval.getBeggining()) 
    {
        this.timeReference = lastInterval.getEnd();
        lastInterval = intervalIterator.next();
    }

    // do more stuff after

}

instead if maybeUpdateTime() is only called by updateState()?

Or if you have performance requirements and don't want to (1) consume more CPU resources,   (2) block other tasks in the same thread, maybe consider put maybeUpdateTime() into a separate thread that allows you to wait for a task to complete (update time).

Source Link
lennon310
  • 3.2k
  • 7
  • 18
  • 34

It's valid but problematic for debugging, performance and reading clarity.

Can you use

void updateState() {

    // do some stuff before

    while (this.timeReference.isAfter(lastInterval.getBeggining()) 
    {
        this.timeReference = lastInterval.getEnd();
        lastInterval = intervalIterator.next();
    }

    // do more stuff after

}

instead if maybeUpdateTime() is only called by updateState()?

Or if you have performance requirements and don't want to (1) consume more CPU resources, or (2) block other tasks in the same thread, maybe consider put maybeUpdateTime() into a separate thread that allows you to wait for a task to complete (update time).