Difference between revisions of "Threading"

From reSIProcate
Jump to navigation Jump to search
m
Line 33: Line 33:
 
== Separate Stack and Transport Threads ==
 
== Separate Stack and Transport Threads ==
  
This model is a hybrid of previous two.  Your application and DUM run in the same thread, the stack itself runs in its own thread, and each transport runs in a seperate thread.  To enable this you must create a multi-threaded stack and pass to the DUM constructor and you must call the dum->run() function - followed by calls to the dum->process() (with no arguments) method.
+
This model is a hybrid of the previous two.  Your application and DUM run in the same thread, the stack itself runs in its own thread, and each transport runs in a seperate thread.  To enable this you must create a multi-threaded stack and pass to the DUM constructor and you must call the dum->run() function - followed by calls to the dum->process() (with no arguments) method.

Revision as of 21:49, 14 March 2005

The Dialog Usage Manager (DUM) supports a few threading options - which are summarized below.

NOTE: There is no threading protection in the DUM methods themseleves. If your application itself is multi-threaded you MUST provide your own protection if you plan on calling dum->process and/or other DUM API's from different threads.


Single Threaded

Your application, DUM, the stack and transports all run in the same thread. This is how the BasicCall sample works. A process loop is required:

  while (!dumShutDown)
  {
     FdSet fdset;
     dum->buildFdSet(fdset);
     int err = fdset.selectMilliSeconds(dum->getTimeTillNextProcessMS());
     assert ( err != -1 );
     dumUas->process(fdset);
  }


Separate Stack Thread

Your application and DUM run in the same thread, the stack and transports run in another thread. To run in this mode you must call dum->run() to startup the stack thread. Then you must periodically call the process() (with no arguments) method so that DUM can peform its processing. The important thing to remember here, is that DUM is not part of the core stack, it sits on top.


Separate Transport Threads

You application, DUM and the stack all run in the same thread. A seperate thread is launched for each transport. To run in this mode you must create a Stack object specifying Multi-Threaded to true and pass this to the DUM constructor.

  std::auto_ptr<SipStack> sipStack(new SipStack(true));
  DialogUsageManager* dumUas = new DialogUsageManager(sipStack); // will cause each of the transports to run in their own threads.


Separate Stack and Transport Threads

This model is a hybrid of the previous two. Your application and DUM run in the same thread, the stack itself runs in its own thread, and each transport runs in a seperate thread. To enable this you must create a multi-threaded stack and pass to the DUM constructor and you must call the dum->run() function - followed by calls to the dum->process() (with no arguments) method.