Re: [Boost-users] Does anybody interested in active object

To Dean Michael Berris:
You'd be better of doing data parallelism with Boost.MPI
No. Because I'm speaking about thread-based parallelism (with shared memory access). Processed-based parallelism and IPC supplement but don't replace thread-based parallelism in general.
Tie this tasks with the data they share and You will have an active object. If the tasks don't have shared data - they don't need an active object. I think - active object is built on task-based parallelism but it does not mean that "active object" should replace "task-based parallelism" everywhere.
But what you're describing is not the active object pattern. ;)
http://en.wikipedia.org/wiki/Active_object http://en.wikipedia.org/wiki/Active_object_(Symbian_OS) What about ma::echo::server::session class - is it an active object? http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio/example/chat/chat_c lient.cpp Is chat_client an active object? If "yes" then why? chat_client::write have no completion callback - and this is not enough sometimes (I can say "always", if You don't implementing "fire-and-forget" logic which is rather seldom). http://www.boost.org/doc/libs/1_44_0/doc/html/boost_asio/example/serializati on/connection.hpp s11n_example::connection is an active object and have completion callback... but it's much simpler then ma::echo::server::session_manager - I try to suggest "samples" that can help to build such a kind of complex active objects. http://www.drdobbs.com/go-parallel/blog/archives/2009/09/parallelism_sho.htm l
Here's the place for active object pattern. Thanks for that attention that you have given to my question. Marat Abrarov.

On Mon, Nov 8, 2010 at 7:11 AM, Marat Abrarov
Well, which is why I said 'data parallelism'. This implies a whole different kind of programming, which doesn't typically include threads and synchronization. ;)
Nope, sorry, that's not an active object. An Active Object requires that you have a at least one thread of execution dedicated to the active object, and that you have a synchronous interface to that object.
If the tasks don't have shared data - they don't need an active object.
Active Objects really have nothing to do with shared data. It's a design pattern that prescribes a way of isolating the synchronization and serialization of operations applied to an object that is assumed to be shared across multiple threads of execution. The way the active object does it is by lining up the operations to be performed asynchronously and perform those in a different thread of execution. You can implement an active object without involving shared data -- for example you want to model a processor, or a math kernel, which does all its work on a single thread because maybe you have a library underneath that is not thread-safe. In situations like these it makes sense to have an active object implementation.
I think you have it wrong. The active object pattern is a design pattern that doesn't know about task-based parallelism. Task-based parallelism is a different pattern and different paradigm altogether. The active object pattern by itself is just a design pattern, nothing more.
I haven't looked at your examples, because I was only commenting on the issue regarding massive parallelism. Maybe when I have enough time I'll look through your examples. ;)
No, this is not an active object. An active object has its own lifetime thread. In this situation the lifetime thread is shared between Boost.Asio's IO subsystem and all the ASIO related handlers. Also, you don't need a completion callback for a class to model the Active Object pattern. You can create methods that return 'void' and just execute the actions asynchronously in its own lifetime thread.
Nope, sorry, s11n_example::connection is not an active object. What it actually is, is an execution context -- or sometimes people call it a continuation, a generator, or a state machine. Because you're using the execution context relevant with a particular connection, it doesn't imply that the operations are performed on a different thread. All this is doing is encapsulating callbacks and the protocol implementation into an object. It exposes a means of asynchronously scheduling operations, but it doesn't hide these details from the interface. The goal of the active object pattern is to hide the asynchronous nature of the implementation from the user of the object.
If you have unlimited number of cores and no limits on the number of threads you can spawn for each active object you create, then yes. Otherwise, you can stick with continuations, asynchronous completion handlers, and just plain data parallelism. The place for an active object is where you have to expose a synchronous interface to a resource which underneath performs the actions asynchronously. This is like the half-sync half-async pattern which, once you understand, is what the active object implementation provides. -- Dean Michael Berris deanberris.com
participants (2)
-
Dean Michael Berris
-
Marat Abrarov