[pjsip] Thread creations and terminations
bennylp at pjsip.org
Mon Nov 19 21:41:34 EST 2007
buldozer at aufbix.org wrote:
> Hello Benny,
>> What if, instead of using callback, you put a flag in the thread, to
>> mark whether the thread has been DAO initialized or not. This can be
> Your suggestion sounds a bit better than what I do at the moment
> (GetLocalThreadId() from within callback and then checking whether the ID is
> already in global list - if not - do AfxDaoInit() and store the thread ID in
> the list), but it suffers the same problem; AfxDaoTerm() never gets called at
> termination of a thread. Any other ideas to make it 'clean'?
Ah yes, good point about AfxDaoTerm(), I missed that.
In this case, the only clean solution probably is to disable pjsua's
SIP worker thread altogether (pjsua_config.thread_cnt=0), and create
your own worker thread(s). Worker thread implementation should be
very simple; it just needs to call pjsua_handle_events()
periodically (see worker_thread() in pjsua_core.c). This worker
thread should be created after pjsua_start(), and it should be
stopped before calling pjsua_destroy().
More information about the pjsip