diff --git a/reference/ArrayCtrlSorting/ArrayCtrlSorting.upp b/reference/ArrayCtrlSorting/ArrayCtrlSorting.upp index 5872304d3..5fd01cace 100644 --- a/reference/ArrayCtrlSorting/ArrayCtrlSorting.upp +++ b/reference/ArrayCtrlSorting/ArrayCtrlSorting.upp @@ -1,3 +1,5 @@ +description "Sorting columns in ArrayCtrl\377"; + uses CtrlLib; diff --git a/reference/AsyncWork/AsyncWork.cpp b/reference/AsyncWork/AsyncWork.cpp new file mode 100644 index 000000000..b15b17153 --- /dev/null +++ b/reference/AsyncWork/AsyncWork.cpp @@ -0,0 +1,37 @@ +#include + +using namespace Upp; + +CONSOLE_APP_MAIN +{ + StdLogSetup(LOG_FILE|LOG_COUT); + + auto a = Async([](int n) -> double { + double f = 1; + for(int i = 2; i <= n; i++) + f *= i; + return f; + }, 100); // Schedules job to be executed by threadpool, returns AsyncWork for the return value and job control + + DUMP(a.Get()); // Makes sure job is finished (can execute it if it has not started yet), returns the result + + auto b = Async([] { throw "error"; }); + + try { + b.Get(); // exception is propagated + } + catch(...) { + LOG("Exception has been caught"); + } + + + auto c = Async([] { + for(;;) + if(CoWork::IsCanceled()) { + LOG("Work was canceled"); + break; + } + }); + Sleep(100); // make it chance to start + // c destructor cancels the work (can be explicitly canceled by Cancel method too) +} diff --git a/reference/AsyncWork/AsyncWork.upp b/reference/AsyncWork/AsyncWork.upp new file mode 100644 index 000000000..0926e969e --- /dev/null +++ b/reference/AsyncWork/AsyncWork.upp @@ -0,0 +1,11 @@ +description "AsyncWork is U++ variant of std::future mechanism\377"; + +uses + Core; + +file + AsyncWork.cpp; + +mainconfig + "" = ""; + diff --git a/reference/EncodeDecode/EncodeDecode.upp b/reference/EncodeDecode/EncodeDecode.upp index 74ffbd776..602c8d451 100644 --- a/reference/EncodeDecode/EncodeDecode.upp +++ b/reference/EncodeDecode/EncodeDecode.upp @@ -1,3 +1,5 @@ +description "Web related encoding / decoding routines\377"; + uses Core;