What does thread_pool_start actually do?

I have just run a multi-threaded device resource manager but perhaps there is a mysterious :neutral_face:
I want to know what thread_pool_start actually does.
Iโ€™m sorry! I increased font size to be easy to view.

thread_pool_attr_t   pool_attr;
pool_attr.handle = dpp;
    pool_attr.context_alloc = (void*)dispatch_context_alloc;
    pool_attr.block_func =(void*)dispatch_block; 
    pool_attr.unblock_func =(void*)dispatch_unblock;
    pool_attr.handler_func =  (void*)dispatch_handler;
    pool_attr.context_free = (void*) dispatch_context_free;[/code]

[size=150]I guess:
-At the first, [b]dispatch_context_alloc[/b] is called and it need a [b]dispatch_t [/b]argument .  This argument is  [b]pool_attr.handle[/b]
- and then, [b]thread_pool_start [/b] calls [b]dispatch_block[/b] but this function needs a [b]dispatch_context_t[/b] argument. But I don't know what will be used as a argument for this funciton.
- and the same question for [b]dispatch_unblock[/b], [b]dispatch_handler[/b]
I viewed fields of thread_pool_attr_. This structure has not any [b]dispatch_context_t[/b] field[/size]

[code]#ifndef THREAD_POOL_PARAM_T
 #define THREAD_POOL_PARAM_T	void

 #define THREAD_POOL_HANDLE_T	dispatch_t

typedef struct _thread_pool_attr {
	void					(*unblock_func)(THREAD_POOL_PARAM_T *ctp);
	int						(*handler_func)(THREAD_POOL_PARAM_T *ctp);
	THREAD_POOL_PARAM_T		*(*context_alloc)(THREAD_POOL_HANDLE_T *handle);
	void					(*context_free)(THREAD_POOL_PARAM_T *ctp);
	pthread_attr_t			*attr;
	unsigned short			lo_water;
	unsigned short			increment;
	unsigned short			hi_water;
	unsigned short			maximum;
	unsigned				reserved[8];
} thread_pool_attr_t;[/code]

[size=150]The only field which can be used is [b]pthread_attr_t			*attr;[/b]
And this is fields of the structure:[/size]

[code]#if defined(__PTHREAD_ATTR_T)
typedef __PTHREAD_ATTR_T	pthread_attr_t;

[code]#define __PTHREAD_ATTR_T \
	struct _thread_attr { \
		int							flags; \
		_Sizet						stacksize; \
		void						*stackaddr; \
		void						(*exitfunc)(void *status); \
		int							policy; \
		struct sched_param			param; \
		unsigned					guardsize; \
		unsigned					prealloc; \
		int							spare[2]; \

dispatch_context_t *dispatch_context_alloc(dispatch_t *dpp); dispatch_context_t *dispatch_block(dispatch_context_t *ctp); void dispatch_unblock(dispatch_context_t *ctp); int dispatch_handler(dispatch_context_t *ctp); void dispatch_context_free(dispatch_context_t *ctp);

No need to speculate, the source code is hereโ€ฆ

community.qnx.com/integration/vi โ€ฆ m=exsy1001

Thanks rgallen! :slight_smile:
It is not simple :smiley: