RE: [Quickfix-users] why threads
Brought to you by:
orenmnero
From: Oren M. <ore...@ya...> - 2003-05-31 14:05:05
|
The only thing that I would add to this (probably because it's not yet documented), is that 1.5.0 also introduces the blockingStart call (contributed by Alex Hornby). Used with the SocketInitiator or SocketAcceptor, you can truly run QF with just one thread. This alleviates the need for using any tricks to keep the application alive if you only need to respond to FIX events and nothing else. --- Bud Griffin <bud...@ya...> wrote: > Hey, > > It's kind of a hard time to try and answer the > question because there > are major differences between QuickFix 1.4.x or > earlier and 1.5.0 when > it comes to threads and the onRun method, you didn't > state which version > of QuickFix you were using. But if you use the code > for backwards > compatibility that Oren describes in the 1.5.0 > Release Announcement or > you're using 1.4.x then you can really ignore the > onRun method and just > put a while (true) sleep(1000000); statement as the > body of the onRun > method or something similar. It may take up an > additional thread that > sleeps a lot; but not a big deal, IMHO. Now, when > you write your > callbacks for toApp/fromApp (or toAdmin/fromAdmin) > they will be executed > within a single thread and any concerns you have for > making the > application thread safe aren't necessary. You code > the callbacks just > like the app is a single threaded, event driven > application w/o having > to worry about contention between global variables, > containers or > whatever. > > If you want to use 1.5.0 as it was intended, it's > really easier and > reduces the thread count. But there are not a lot > of examples (at this > point). First move the while (true) sleep > (1000000); to your main() > routine (or do something more useful) just after > your call to the > initiator.start() method and don't bother overriding > the onRun method. > This make the main thread wait forever. Once again > all of the callbacks > you overrode from the Application class will be > within the same thread > and you don't have to worry, plus there's 1 less > thread. > > If you're really concerned, QuickFix has a > SynchronizedApplication class > to use instead of the Application class that uses a > set/clear a mutex > around all of the FIX protocol callbacks. > > I do disagree with your concern over multiple > threads being used by > QuickFix, the fact that I don't have to worry about > QuickFix taking care > of its own threads under Unix or Windows has made my > life much easier. > In the FIX apps I've written there always seems to > be something else I > have to deal with; another socket connection for > non-FIX protocols or a > market data feed vendor's API, etc. These situations > seem to be more > easily handled by another thread; even though I have > to deal with the > synchronization issues between the data > classes/containers I've created > to share the info. > > Take care, > Bud > > -----Original Message----- > From: qui...@li... > [mailto:qui...@li...] > On Behalf Of > ma...@Ge... > Sent: Friday, May 30, 2003 2:55 PM > To: QuickFix > Subject: [Quickfix-users] why threads > > > Hi, > > I am using SocketInitiator expecting to have a > non-threaded application. > However, when my application starts in my debugger > (gdb) it reports > three > threads running. Why? What do I have to do to make > my application > thread > safe? > > (gdb) run > Starting program: > /home/marc/src/quickfix/atoms/atoms > [New Thread 1024 (LWP 21677)] > [New Thread 2049 (LWP 21678)] > [New Thread 1026 (LWP 21679)] > [Switching to Thread 1026 (LWP 21679)] > > Breakpoint 1, Application::onRun (this=0xbffffbf0) > at > Application.C:188 > (gdb) > > Thank you, > Marc > > > PS. Hi Aaron!!!! > --------------------------------------------------------------------- > Marc Schwarzschild > 1-646-825-2163 > Gerber Capital Management Inc. > 120 Broadway, NYC > > Confidentiality note: This e-mail contains > information from Gerber > Capital > Management,Inc and/or its affiliates that is > confidential and/or legally > privileged. This information is intended only for > the use of the > individual > or entity named on this e-mail. This e-mail and its > content may > not be reproduced or retransmitted without the > express written > permission of > Gerber Capital Management,Inc. > Sent via wireless > > > ------------------------------------------------------- > This SF.net email is sponsored by: eBay > Get office equipment for less on eBay! > http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5 > _______________________________________________ > Quickfix-users mailing list > Qui...@li... > https://lists.sourceforge.net/lists/listinfo/quickfix-users > > > > ------------------------------------------------------- > This SF.net email is sponsored by: eBay > Get office equipment for less on eBay! > http://adfarm.mediaplex.com/ad/ck/711-11697-6916-5 > _______________________________________________ > Quickfix-users mailing list > Qui...@li... > https://lists.sourceforge.net/lists/listinfo/quickfix-users __________________________________ Do you Yahoo!? Yahoo! Calendar - Free online calendar with sync to Outlook(TM). http://calendar.yahoo.com |