Opened 21 years ago
Closed 21 years ago
#16 closed Feature Requests (None)
way to defer thread creation needed
| Reported by: | nobody | Owned by: | nobody |
|---|---|---|---|
| Milestone: | Component: | thread | |
| Version: | None | Severity: | |
| Keywords: | Cc: |
Description
It is not now currently possible to defer boost thread creation to a later time without creating a
wrapper class for the thread class. Starting a thread immediately in a constructor is not always
desirable. Sometimes you require other members in your class to be initialized before the thread,
for example. Or perhaps your class may have many threads that have to all be initialized before
any of them can be created.
I propose a new member function: thread::start(const function0<void>& threadfunc) to accomplish
this goal. To use this new function you could do something like:
boost::thread thrd; // notice no function specified
thrd.start(thread_alarm(secs));
or perhaps thread::start() could take no parameters and an new alternate thread constructor could
be added that would not execute the thread right away:
// thread class could have an enum { execute, defer }
boost::thread thrd(thread_alarm(secs), boost::thread::defer);
thrd.start();
The latter form has the advantage of the caller of start() need not being concerned with what
function is being invoked.
Note:
See TracTickets
for help on using tickets.
