From 0acff566213fdddbc8f4561887aced121f82dc26 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 23 Apr 2014 18:12:53 -0400 Subject: 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. --- libdimension/dimension/future.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'libdimension/dimension') diff --git a/libdimension/dimension/future.h b/libdimension/dimension/future.h index f0693b9..9f1f14a 100644 --- a/libdimension/dimension/future.h +++ b/libdimension/dimension/future.h @@ -1,5 +1,5 @@ /************************************************************************* - * Copyright (C) 2009-2011 Tavian Barnes * + * Copyright (C) 2009-2014 Tavian Barnes * * * * This file is part of The Dimension Library. * * * @@ -57,3 +57,16 @@ double dmnsn_future_progress(const dmnsn_future *future); * @param[in] progress The progress value to wait for. */ void dmnsn_future_wait(const dmnsn_future *future, double progress); + +/** + * Pause all threads working on the given future. Once this function returns, + * it is safe to examine the intermediate state of the asynchronous computation. + * @param[in,out] future The background task to pause. + */ +void dmnsn_future_pause(dmnsn_future *future); + +/** + * Resume a previously paused future object. + * @param[in,out] future The background task to resume. + */ +void dmnsn_future_resume(dmnsn_future *future); -- cgit v1.2.3