Shared Thread Pool (Windows Embedded CE 6.0)
1/6/2010
Only the HCI layer maintains two persistent threads; write and read. Other layers borrow threads from the top or bottom layers of the stack as they are called with commands and events.
To increase the efficiency and facilitate shutdown logic, thread layers are discouraged from maintaining their own thread pools as well as creating new threads using the CreateThread mechanism.
The Bluetooth stack provides a shared thread pool accessible through the following set of functions.
SVSCookie btutil_ScheduleEvent (
LPTHREAD_START_ROUTINE pfn,
LPVOID lpParameter,
unsigned long ulDelayTime
);
int btutil_UnScheduleEvent (SVSCookie ulCookie);
By using these functions, stack layers are guaranteed the threads will be properly stopped before the stack is unloaded.