5 Commits

Author SHA1 Message Date
Johan Wikman
f546a17e77 Update change date of 2.2 2017-06-01 10:24:20 +03:00
Johan Wikman
f66620c89c Accept auto_ptr<T> where T is derived type
Without the member template it is not possible to pass an auto_ptr
instantiated with a derived type to post() or broadcast().

The reason is that the conversion constructor and conversion
operator of auto_ptr are equally good for that purpose, and hence
the compilation ends with an error.
2017-05-08 09:36:16 +03:00
Johan Wikman
6c4a4a3ee0 Do not inherit WorkerDisposableTask from WorkerTask
WorkerDisposableTask is intended to be passed using auto_ptr, to
make it plain that the ownership is moved. If it's inherited from
WorkerTask it can be passed as a WorkerTask, which is confusing as
it in that case will not be disposed of.
2017-05-04 14:06:44 +03:00
Johan Wikman
55011c2951 Add safety check and rename ref mgmt functions 2017-04-25 13:10:01 +03:00
Johan Wikman
8174690f77 Introduce concept of Worker tasks
A Worker::Task is an object that can be sent to a worker for
execution. The task is sent to the worker using the messaging
mechanism where the `execute` function of the task will be
called in the thread context of the worker.

There are two kinds of tasks; regular tasks and disposable tasks.
The former are just sent to the worker for execution while the
latter are sent and subsequently disposed of, once the task has
been executed.

A disposable task can be sent to either one worker or to all
workers. In the latter case, the task will be deleted once it
has been executed by all workers.

A semaphore can be associated with a regular task. Once the task
has been executed by the worker, the semaphore will automatically
be posted. That way, it is trivial to send a task for execution
to a worker and wait until the task has been executed. For instance:

    Semaphore sem;
    MyTask task;

    pWorker->execute(&task, &sem);
    sem.wait();

    const MyResult& result = task.result();

The low level mechanism for posting and broadcasting messages will
be removed.
2017-04-24 14:52:54 +03:00