summaryrefslogtreecommitdiffstats
path: root/libdimension/tests
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2014-04-23 18:12:53 -0400
committerTavian Barnes <tavianator@tavianator.com>2014-04-23 22:41:21 -0400
commit0acff566213fdddbc8f4561887aced121f82dc26 (patch)
tree97620a5ef72efc783d35817e4349a9f8a1d8cff8 /libdimension/tests
parent3ce3ed46f5cd95bfca4f9303c93859fac54476bb (diff)
downloaddimension-0acff566213fdddbc8f4561887aced121f82dc26.tar.xz
future: Add a race-free way to examine a partial computation.
This allows safe OpenGL previews, for example. dmnsn_future* learned the dmnsn_future_{pause,resume}() functions which cause all worker threads to block. render.test now survives Helgrind with no errors.
Diffstat (limited to 'libdimension/tests')
-rw-r--r--libdimension/tests/render.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/libdimension/tests/render.c b/libdimension/tests/render.c
index 58a7930..1efff28 100644
--- a/libdimension/tests/render.c
+++ b/libdimension/tests/render.c
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2010-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2010-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Test Suite. *
* *
@@ -367,12 +367,15 @@ main(void)
/* Display the scene as it's rendered */
if (display) {
while (dmnsn_future_progress(future) < 1.0) {
- if (dmnsn_gl_write_canvas(scene->canvas) != 0) {
- dmnsn_delete_display(display);
- dmnsn_delete_scene(scene);
- fprintf(stderr, "--- Drawing to OpenGL failed! ---\n");
- return EXIT_FAILURE;
- }
+ dmnsn_future_pause(future);
+ if (dmnsn_gl_write_canvas(scene->canvas) != 0) {
+ dmnsn_delete_display(display);
+ dmnsn_delete_scene(scene);
+ fprintf(stderr, "--- Drawing to OpenGL failed! ---\n");
+ return EXIT_FAILURE;
+ }
+ dmnsn_future_resume(future);
+
dmnsn_display_flush(display);
}
}