From: TazaTek on 7 Apr 2010 15:20 I need some help determining if I have the right design pattern, or if there's a better one I should consider... I'm designing a stock charting program in C++ and wanted to get some advice / direction from others that have more experience than I do. I'm 1st tackling the problem of the incoming real-time datafeed (via TCP from a provider or in-house sim pumper) that is then routed to various charts (and other consumers of the data). I am initially thinking that an Observer/Subject model would work for this, but I didn't know if there were any "gotchas" to this approach, or if it's even the right tool for the job. Speed is a major design consideration, so a push model is likely favored over a pull model. (up to 500 symbols getting updated several times/sec) Are there any other designs or considerations that will allow for a low latency, high throughput data processor like this? Are there any examples out there that anyone knows of? I've found some generalized Observer patterns, but none of them address specifically a real-time data feed. Thanks Matt
From: Daniel T. on 7 Apr 2010 18:40 In article <d4ddfad4-ef1a-4efb-be2c-aa2bae01981d(a)e7g2000yqf.googlegroups.com>, TazaTek <kettlewell.enterprises.inc(a)gmail.com> wrote: > I need some help determining if I have the right design pattern, or if > there's a better one I should consider... > > I'm designing a stock charting program in C++ and wanted to get some > advice / direction from others that have more experience than I do. > > I'm 1st tackling the problem of the incoming real-time datafeed (via > TCP from a provider or in-house sim pumper) that is then routed to > various charts (and other consumers of the data). > > I am initially thinking that an Observer/Subject model would work for > this, but I didn't know if there were any "gotchas" to this approach, > or if it's even the right tool for the job. > > Speed is a major design consideration, so a push model is likely > favored over a pull model. > (up to 500 symbols getting updated several times/sec) > > Are there any other designs or considerations that will allow for a > low latency, high throughput data processor like this? > > Are there any examples out there that anyone knows of? > > I've found some generalized Observer patterns, but none of them > address specifically a real-time data feed. I agree with you that a observer pattern with a push model would be a good solution. Something that worked well for me in a past project was this: template < typename Observer > class Subject { std::set< Observer* > observers; public: void attach( Observer* o ) { observers.insert( o ); } void detach( Observer* o ) { observers.erase( o ); } template < typename ConcreteSubject > void notify( const ConcreteSubject* cs, void (Observer::*fn)( const ConcreteSubject* ) ) { std::set< Observer* >::iterator it = observers.begin(); while ( it != observers.end() ) { Observer* ob( *it++ ); (ob->*fn)( cs ); } } };
From: TazaTek on 8 Apr 2010 08:43 > I agree with you that a observer pattern with a push model would be a > good solution. > > Something that worked well for me in a past project was this: > Thanks Daniel. I'll give it a go. Matt
|
Pages: 1 Prev: Singularity Alert for OO AI in Ruby & Javascript Next: Real Time Data Feed Design Questions |