mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-11 07:10:36 +00:00
add mutex/lock to singlethread mode threadpool
remove uneeded i2p.rock.signed.txt update makefile clean target
This commit is contained in:
parent
5c03b3c8f9
commit
066c208622
3
Makefile
3
Makefile
@ -34,9 +34,10 @@ TESTNET_DEBUG ?= 0
|
|||||||
clean:
|
clean:
|
||||||
rm -f build.ninja rules.ninja cmake_install.cmake CMakeCache.txt
|
rm -f build.ninja rules.ninja cmake_install.cmake CMakeCache.txt
|
||||||
rm -rf CMakeFiles
|
rm -rf CMakeFiles
|
||||||
rm -f $(TARGETS) llarpd
|
rm -f $(TARGETS) llarpd llarpc dns rcutil testAll
|
||||||
rm -f $(SHADOW_PLUGIN) $(SHADOW_CONFIG)
|
rm -f $(SHADOW_PLUGIN) $(SHADOW_CONFIG)
|
||||||
rm -f *.sig
|
rm -f *.sig
|
||||||
|
rm -f *.a *.so
|
||||||
|
|
||||||
debug-configure:
|
debug-configure:
|
||||||
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DWITH_TESTS=ON -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX)
|
cmake -GNinja -DCMAKE_BUILD_TYPE=Debug -DWITH_TESTS=ON -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX)
|
||||||
|
@ -92,7 +92,6 @@ def main():
|
|||||||
f.write('''[test-service]
|
f.write('''[test-service]
|
||||||
tag=test
|
tag=test
|
||||||
prefetch-tag=test
|
prefetch-tag=test
|
||||||
prefetch-tag=nonexist
|
|
||||||
''')
|
''')
|
||||||
|
|
||||||
with open(args.out, 'w') as f:
|
with open(args.out, 'w') as f:
|
||||||
@ -100,20 +99,22 @@ prefetch-tag=nonexist
|
|||||||
directory = {}
|
directory = {}
|
||||||
command = {}
|
command = {}
|
||||||
redirect_stderr=true
|
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
|
stdout_logfile_maxbytes=0
|
||||||
process_name = svc-node-%(process_num)03d
|
process_name = svc-node-%(process_num)03d
|
||||||
numprocs = {}
|
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]
|
f.write('''[program:client-node]
|
||||||
directory = {}
|
directory = {}
|
||||||
command = {}
|
command = {}
|
||||||
redirect_stderr=true
|
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
|
stdout_logfile_maxbytes=0
|
||||||
process_name = client-node-%(process_num)03d
|
process_name = client-node-%(process_num)03d
|
||||||
numprocs = {}
|
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')
|
f.write('[supervisord]\ndirectory=.\n')
|
||||||
|
|
||||||
|
|
||||||
|
Binary file not shown.
@ -38,7 +38,7 @@ namespace llarp
|
|||||||
#elif !defined(_MSC_VER) || !defined(_WIN32)
|
#elif !defined(_MSC_VER) || !defined(_WIN32)
|
||||||
pthread_setname_np(pthread_self(), name);
|
pthread_setname_np(pthread_self(), name);
|
||||||
#else
|
#else
|
||||||
SetThreadName(GetCurrentThreadId(),name);
|
SetThreadName(GetCurrentThreadId(), name);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
for(;;)
|
for(;;)
|
||||||
@ -103,6 +103,7 @@ struct llarp_threadpool
|
|||||||
{
|
{
|
||||||
llarp::thread::Pool *impl;
|
llarp::thread::Pool *impl;
|
||||||
|
|
||||||
|
std::mutex m_access;
|
||||||
std::queue< llarp_thread_job * > jobs;
|
std::queue< llarp_thread_job * > jobs;
|
||||||
|
|
||||||
llarp_threadpool(int workers, const char *name)
|
llarp_threadpool(int workers, const char *name)
|
||||||
@ -169,8 +170,16 @@ llarp_threadpool_queue_job(struct llarp_threadpool *pool,
|
|||||||
{
|
{
|
||||||
if(pool->impl)
|
if(pool->impl)
|
||||||
pool->impl->QueueJob(job);
|
pool->impl->QueueJob(job);
|
||||||
else
|
else if(job.user && job.work)
|
||||||
pool->jobs.push(new llarp_thread_job(job));
|
{
|
||||||
|
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
|
void
|
||||||
@ -178,11 +187,14 @@ llarp_threadpool_tick(struct llarp_threadpool *pool)
|
|||||||
{
|
{
|
||||||
while(pool->jobs.size())
|
while(pool->jobs.size())
|
||||||
{
|
{
|
||||||
auto &job = pool->jobs.front();
|
llarp_thread_job *job;
|
||||||
if(job && job->work && job->user)
|
{
|
||||||
job->work(job->user);
|
std::unique_lock< std::mutex > lock(pool->m_access);
|
||||||
|
job = pool->jobs.front();
|
||||||
|
pool->jobs.pop();
|
||||||
|
}
|
||||||
|
job->work(job->user);
|
||||||
delete job;
|
delete job;
|
||||||
pool->jobs.pop();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user