5 ms·
Qt/C++ users can now use futures with .then() and .await() constructs through this tasks[1] library. an example of .then() construct is here[2]. an example of
by mhogomchungu 12y ago
Qt/C++ users can now use futures with .then() and .await() constructs through this tasks[1] library.
an example of .then() construct is here[2].
an example of .await() construct is here[3].What happens here is the following:
1. The function is suspected at that line.This suspension does not block the thread and hence the GUI remains responsive.
2. A thread is created and the lambda is run in the new thread.
3. When the lambda completes,the function is unblocked and finish up its work.
The above gives easy to read and non blocking synchronous code.
[1] https://github.com/mhogomchungu/tasks https://github.com/mhogomchungu/tasks
[2] https://github.com/mhogomchungu/zuluCrypt/blob/d0439a4e36521e42fa9392b82dcefd3224d53334/zuluMount-gui/mainwindow.cpp#L812 https://github.com/mhogomchungu/zuluCrypt/blob/d0439a4e36521...
[3] https://github.com/mhogomchungu/zuluCrypt/blob/eadd2643291f37d8dc96302d854f1ae8e29758d9/zuluCrypt-gui/createkeyfile.cpp#L169 https://github.com/mhogomchungu/zuluCrypt/blob/eadd2643291f3...