Commit d31b2a4a authored by Davis King's avatar Davis King

Changed the future object so that its destructor waits

for any tasks in a thread_pool that use the future to stop
before letting a future go out of scope.

--HG--
extra : convert_revision : svn%3Afdd8eb12-d10e-0410-9acb-85c331704f74/trunk%402689
parent 504382e1
...@@ -51,6 +51,9 @@ namespace dlib ...@@ -51,6 +51,9 @@ namespace dlib
const future& item const future& item
) :task_id(0), tp(0), var(item.get()) {} ) :task_id(0), tp(0), var(item.get()) {}
~future (
) { wait(); }
future& operator=( future& operator=(
const T& item const T& item
) { get() = item; return *this; } ) { get() = item; return *this; }
......
...@@ -73,11 +73,26 @@ namespace dlib ...@@ -73,11 +73,26 @@ namespace dlib
- #get() == item.get() - #get() == item.get()
!*/ !*/
~future (
);
/*!
requires
- if (item.is_ready() == false) then
- The thread_pool that this future was passed to should still exist
(i.e. You can't pass a future to a thread_pool and then destruct the
thread_pool before you destruct the future).
ensures
- if (item.is_ready() == false) then
- the call to this function blocks until the thread processing the task related
to the item future has finished.
!*/
bool is_ready ( bool is_ready (
) const; ) const;
/*! /*!
ensures ensures
- if (the value of this future may not yet be ready to be accessed because it is in use by a task in a thread_pool) then - if (the value of this future may not yet be ready to be accessed because it
is in use by a task in a thread_pool) then
- returns false - returns false
- else - else
- returns true - returns true
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment