Welcome!

The project "Improvements to std::future and Related APIs" (codename "Indigo") is a prototype implementation of proposals to JTC1/SC22/WG21 available here:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3634.pdf
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3637.pdf

The source code contains separate versions of the future header file compatible with Visual Studio 2012 and Visual Studio 2013 Preview, but the samples are for VS 2012 only.

Futures and Continuations

In C++ 11, std::future is great way of decomposing a program into concurrent parts, but a poor way of composing these parts into a responsive and scalable program. We're proposing a set of addition to std::future to facilitate writing scalable and non-blocking code.

In the example below, instead of waiting for the file to be copied on the GUI thread, we set a continuation in the then method:

  copy_file(src, dst).then(gui_scheduler, [](std::future<void>) {
      SetWindowText(hWndBtn, L"File copy done!");
  });

Getting Started

To get started, you need to update the file future in your Visual Studio 2012 installation. Alternatively, you can run the following script (replacing the underlying hardcoded path below)

@echo off
setlocal

REM change this:
SET NEW_FUTURE=D:\indigo\vc\include\future

if exist "%NEW_FUTURE%" goto continue
echo Cannot find file %NEW_FUTURE%, update failed
goto done

:continue
SET VS_DIR=
for /F "tokens=1,2*" %%i in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\11.0_Config" /v "ShellFolder"') DO (
    if "%%i"=="ShellFolder" (
        SET "VS_DIR=%%k"
    )
)

if exist "%VS_DIR%VC\include\backup" goto backup_exists
md %VS_DIR%VC\include\backup
echo creating backup:
echo copying "%VS_DIR%VC\include\future" to "%VS_DIR%VC\include\backup\future"
copy %VS_DIR%VC\include\future %VS_DIR%VC\include\backup\future
copy /v /y %NEW_FUTURE% %VS_DIR%VC\include
if "%errorlevel%"=="0" goto done
echo Cannot copy file %NEW_FUTURE%, update failed
goto done

:backup_exists
echo The file has not been updated to avoid overriding the backup
goto done

:done

Feedback

Use CodePlex discussions or send email directly to artur.laksberg@microsoft.com

Last edited Jul 9, 2013 at 5:17 PM by niklasgu, version 14