Anurag Agarwal ea57934db6 Java 11 migrate c-d (remaining) (#1111)
* Moves converter pattern to Java 11

* Moves cqrs pattern to Java 11

* Moves dao pattern to Java 11

* Moves data-bus pattern to Java 11

* Moves data-locality pattern to Java 11

* Moves data-mapper pattern to Java 11

* Moves data-transfer-object pattern to Java 11

* Moves decorator pattern to Java 11

* Moves delegation pattern to Java 11

* Moves dependency-injection to Java 11

* Moves dirty-flag to Java 11

* Moves double-buffer to Java 11

* Moves double-checked-locking to Java 11

* Moves double-dispatch to Java 11

* Corrects with changes thats breaking test cases
2019-12-14 20:32:45 +02:00
..

layout, title, folder, permalink, categories, tags
layout title folder permalink categories tags
pattern Double Buffer double-buffer /patterns/double-buffer/ Behavioral
Performance
Game programming

Intent

Double buffering is a term used to describe a device that has two buffers. The usage of multiple buffers increases the overall throughput of a device and helps prevents bottlenecks. This example shows using double buffer pattern on graphics. It is used to show one image or frame while a separate frame is being buffered to be shown next. This method makes animations and games look more realistic than the same done in a single buffer mode.

Class diagram

alt text

Applicability

This pattern is one of those ones where youll know when you need it. If you have a system that lacks double buffering, it will probably look visibly wrong (tearing, etc.) or will behave incorrectly. But saying, “youll know when you need it” doesnt give you much to go on. More specifically, this pattern is appropriate when all of these are true:

  • We have some state that is being modified incrementally.
  • That same state may be accessed in the middle of modification.
  • We want to prevent the code thats accessing the state from seeing the work in progress.
  • We want to be able to read the state and we dont want to have to wait while its being written.

Credits