add mutex/lock to singlethread mode threadpool

remove uneeded i2p.rock.signed.txt

update makefile clean target
This commit is contained in:
Jeff Becker 2018-08-03 07:26:14 +10:00
parent 5c03b3c8f9
commit 066c208622
4 changed files with 27 additions and 13 deletions

View File

@ -34,9 +34,10 @@ TESTNET_DEBUG ?= 0
clean:
rm -f build.ninja rules.ninja cmake_install.cmake CMakeCache.txt
rm -rf CMakeFiles
rm -f $(TARGETS) llarpd
rm -f $(TARGETS) llarpd llarpc dns rcutil testAll
rm -f $(SHADOW_PLUGIN) $(SHADOW_CONFIG)
rm -f *.sig
rm -f *.a *.so
debug-configure:
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DWITH_TESTS=ON -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX)

View File

@ -92,7 +92,6 @@ def main():
f.write('''[test-service]
tag=test
prefetch-tag=test
prefetch-tag=nonexist
''')
with open(args.out, 'w') as f:
@ -100,20 +99,22 @@ prefetch-tag=nonexist
directory = {}
command = {}
redirect_stderr=true
stdout_logfile=/dev/fd/1
#stdout_logfile=/dev/fd/1
stdout_logfile={}/svc-node-%(process_num)03d-log.txt
stdout_logfile_maxbytes=0
process_name = svc-node-%(process_num)03d
numprocs = {}
'''.format(os.path.join(args.dir, 'svc-node-%(process_num)03d'), args.bin, args.svc))
'''.format(os.path.join(args.dir, 'svc-node-%(process_num)03d'), args.bin, args.dir, args.svc))
f.write('''[program:client-node]
directory = {}
command = {}
redirect_stderr=true
stdout_logfile=/dev/fd/1
#stdout_logfile=/dev/fd/1
stdout_logfile={}/client-node-%(process_num)03d-log.txt
stdout_logfile_maxbytes=0
process_name = client-node-%(process_num)03d
numprocs = {}
'''.format(os.path.join(args.dir, 'client-node-%(process_num)03d'), args.bin, args.clients))
'''.format(os.path.join(args.dir, 'client-node-%(process_num)03d'),args.bin, args.dir, args.clients))
f.write('[supervisord]\ndirectory=.\n')

Binary file not shown.

View File

@ -38,7 +38,7 @@ namespace llarp
#elif !defined(_MSC_VER) || !defined(_WIN32)
pthread_setname_np(pthread_self(), name);
#else
SetThreadName(GetCurrentThreadId(),name);
SetThreadName(GetCurrentThreadId(), name);
#endif
}
for(;;)
@ -103,6 +103,7 @@ struct llarp_threadpool
{
llarp::thread::Pool *impl;
std::mutex m_access;
std::queue< llarp_thread_job * > jobs;
llarp_threadpool(int workers, const char *name)
@ -169,8 +170,16 @@ llarp_threadpool_queue_job(struct llarp_threadpool *pool,
{
if(pool->impl)
pool->impl->QueueJob(job);
else
pool->jobs.push(new llarp_thread_job(job));
else if(job.user && job.work)
{
auto j = new llarp_thread_job;
j->work = job.work;
j->user = job.user;
{
std::unique_lock< std::mutex > lock(pool->m_access);
pool->jobs.push(j);
}
}
}
void
@ -178,11 +187,14 @@ llarp_threadpool_tick(struct llarp_threadpool *pool)
{
while(pool->jobs.size())
{
auto &job = pool->jobs.front();
if(job && job->work && job->user)
job->work(job->user);
llarp_thread_job *job;
{
std::unique_lock< std::mutex > lock(pool->m_access);
job = pool->jobs.front();
pool->jobs.pop();
}
job->work(job->user);
delete job;
pool->jobs.pop();
}
}