Re: What's the connection between objects and threads?
Whoops! sorry for the last post, I sent it prematurely. :^(
"Chris Thomasson" <cristom@comcast.net> wrote in message
news:OPWdnfiu6IgyB6nVnZ2dnUVZ_vninZ2d@comcast.com...
"Szabolcs Ferenczi" <szabolcs.ferenczi@gmail.com> wrote in message
news:f5f302bb-b577-4041-86d9-f569b0320e8d@e39g2000hsf.googlegroups.com...
[...]
This works fairly well because the run<T> template has nothing to do
with
any active object state. It only ensures that the object has been fully
constructed __before__ the thread which drives it has been created...
Any thoughts?
So far so good. I still have to check it out but this is something I
was looking for. If we replace the term `run' with `active' or
something of a more meaningful term, we are done.
Indeed. I think `active' is a good choice. After that chance you could do
stuff like:
class reader : public thread_base { ... };
what do you think about this tweak:
____________________________________________________________________
namespace active {
class base {
virtual void on_active() = 0;
public:
void activate() { ... };
void wait() { ... };
};
template<typename T>
class object {
T& m_objref;
public:
active(T& objref) : m_objref(objref) {
m_objref.activate();
}
~active() throw() { m_objref.wait(); }
T& get() { return m_objref; }
T const& get() const { return m_objref; }
};
}
/* user code */
class foo : public active::base {
void on_active() { [...]; }
};
int main() {
{ active::object<foo> this_foo; }
return 0;
}
____________________________________________________________________
[...]