On 29.01.2017 1:40, Brian Matherly wrote:
> I've not used the slices module nor studied it deeply. So here are some
> random comments for your consideration.
>
> * Who would be responsible for *first* initializing the global pool?
>
> * Whoever calls it first "wins" by being able to decide the number of
> threads. Maybe the number of threads should not be a parameter to
>
> mlt_slices_init_global_pool(). It could be an environment variable, instead.
>

mlt_slices.c:
[...]
static pthread_mutex_t pool_lock = PTHREAD_MUTEX_INITIALIZER;
[...]

it could be used to manage global pool instances creating


> * Should there also be a mlt_slices_close_global_pool() so that the library 
> can be shut down cleanly? Alternately, you could register the pool 
> withmlt_factory_register_for_clean_up() in mlt_slices_init_global_pool(). For 
> that matter, the global pool could be created bymlt_factory_init().
>
> * I wonder if the global pool should be initialized and closed by the 
> application. Or maybe as part of some other initialization 
> likemlt_factory_init()
>
> * Theoretically speaking, MLT could do well with only two global thread
> pools: one for high priority tasks and one for normal priority tasks.
> Maybe there should only be two thread pools, they could both be global
> and services would be discouraged from creating additional pools.
> Additionally, in this hypothetical scenario, there would only be two
> thread counts to worry about: the number of global high priority threads
> and the number of global normal priority threads.

i like this idea.

to simplify user's interaction with global pool, i would suggest to add 
three additional functions:

[...]
void mlt_slices_run_(rt|normal|idle)(int jobs, mlt_slices_proc proc, 
void* cookie )
{
     return void mlt_slices_run( 
mlt_slices_get_global_ctx(RT|NORMAL|IDLE), jobs, proc, cookie );
}
[...]

function *mlt_slices_get_global_ctx* would be used to initialize a 
global pool context:

[...]
enum { RT, NORMAL, IDLE, LAST }

static mlt_slices globals[LAST] = { NULL, NULL, NULL};

mlt_slices mlt_slices_get_global_ctx(int type)
{
     pthread_mutex_lock( &pool_lock );

     if(!globals[type])
     {
         globals[type] = mlt_slices_init( 0, policy, priority );
         mlt_factory_register_for_clean_up( globals[type], 
mlt_slices_close );
     }

     pthread_mutex_unlock( &pool_lock );

     return globals[type];
};
[...]

threads count could be overridden by *MLT_GLOBAL_SLICES_COUNT*

-- 
Maksym Veremeyenko
Senior System Administrator
IT Department
Ukrainian Music Television Channel "M1"

DDI. +380 44 205-44-92
Tel. +380 44 205-44-80
Fax. +380 44 205-44-82
Cell. +380-67-447-22-43

E-mail : maksym.veremeye...@m1stereo.tv
Web site: www.m1stereo.tv

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to