2012-06-13 15:05:17 +04:00
/*
* Unix SMB / CIFS implementation .
* sync dummy implementation of the pthreadpool API
* Copyright ( C ) Volker Lendecke 2009
*
* This program is free software ; you can redistribute it and / or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation ; either version 3 of the License , or
* ( at your option ) any later version .
*
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
*
* You should have received a copy of the GNU General Public License
* along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
2016-08-15 14:59:12 +03:00
# include "replace.h"
2012-06-13 15:05:17 +04:00
# include "pthreadpool.h"
struct pthreadpool {
2018-04-25 15:03:30 +03:00
bool stopped ;
2012-06-13 15:05:17 +04:00
/*
2016-08-15 14:59:12 +03:00
* Indicate job completion
2012-06-13 15:05:17 +04:00
*/
2016-08-15 14:59:12 +03:00
int ( * signal_fn ) ( int jobid ,
2016-07-31 09:57:35 +03:00
void ( * job_fn ) ( void * private_data ) ,
void * job_fn_private_data ,
2016-08-15 14:59:12 +03:00
void * private_data ) ;
2016-07-31 09:57:35 +03:00
void * signal_fn_private_data ;
2012-06-13 15:05:17 +04:00
} ;
2016-08-15 14:59:12 +03:00
int pthreadpool_init ( unsigned max_threads , struct pthreadpool * * presult ,
int ( * signal_fn ) ( int jobid ,
2016-07-31 09:57:35 +03:00
void ( * job_fn ) ( void * private_data ) ,
void * job_fn_private_data ,
2016-08-15 14:59:12 +03:00
void * private_data ) ,
2016-07-31 09:57:35 +03:00
void * signal_fn_private_data )
2012-06-13 15:05:17 +04:00
{
struct pthreadpool * pool ;
pool = ( struct pthreadpool * ) calloc ( 1 , sizeof ( struct pthreadpool ) ) ;
if ( pool = = NULL ) {
return ENOMEM ;
}
2018-04-25 15:03:30 +03:00
pool - > stopped = false ;
2016-08-15 14:59:12 +03:00
pool - > signal_fn = signal_fn ;
2016-07-31 09:57:35 +03:00
pool - > signal_fn_private_data = signal_fn_private_data ;
2012-06-13 15:05:17 +04:00
2016-08-15 14:59:12 +03:00
* presult = pool ;
2012-06-13 15:05:17 +04:00
return 0 ;
}
2018-06-22 01:49:33 +03:00
size_t pthreadpool_max_threads ( struct pthreadpool * pool )
{
return 0 ;
}
size_t pthreadpool_queued_jobs ( struct pthreadpool * pool )
{
return 0 ;
}
2012-06-13 15:05:17 +04:00
int pthreadpool_add_job ( struct pthreadpool * pool , int job_id ,
void ( * fn ) ( void * private_data ) , void * private_data )
{
2018-04-25 15:03:30 +03:00
if ( pool - > stopped ) {
return EINVAL ;
}
2012-06-13 15:05:17 +04:00
fn ( private_data ) ;
2016-07-31 09:57:35 +03:00
return pool - > signal_fn ( job_id , fn , private_data ,
pool - > signal_fn_private_data ) ;
2012-06-13 15:05:17 +04:00
}
2018-04-20 16:00:31 +03:00
size_t pthreadpool_cancel_job ( struct pthreadpool * pool , int job_id ,
void ( * fn ) ( void * private_data ) , void * private_data )
{
return 0 ;
}
2018-04-25 15:03:30 +03:00
int pthreadpool_stop ( struct pthreadpool * pool )
{
pool - > stopped = true ;
return 0 ;
}
2012-06-13 15:05:17 +04:00
int pthreadpool_destroy ( struct pthreadpool * pool )
{
free ( pool ) ;
return 0 ;
}