He Shiming

Shanghai, China

kaoya.com

Age: 33

Creator of Bizble, 雅思听力宝, 考鸭, Toppin'Wiper, MediaMan and Goals.io.

Independent developer of desktop, web, and mobile platforms.

UI designer.

Aug
26
answered C Language: popen() with fread()?
Aug
21
comment Python, launch concurrent.futures.ProcessPoolExecutor with initialization?
Yes, I can confirm that. It's surprising that the global is per child. I'll take some time to digest and adapt this solution. Thanks for the explanation.
Aug
21
accepted Python, launch concurrent.futures.ProcessPoolExecutor with initialization?
Aug
21
comment Python, launch concurrent.futures.ProcessPoolExecutor with initialization?
But umm... initresult is global. In my case, each child will have to have a separate copy. And I'm not sure if it's picklable, it's not really...
Aug
21
revised Python, launch concurrent.futures.ProcessPoolExecutor with initialization?
added 185 characters in body
Aug
21
comment Python, launch concurrent.futures.ProcessPoolExecutor with initialization?
It might be the problem with wording of my question. But in my case, the function f(x) need to have access to the returned result from initfunc. And each child should have its own copy. I'm not seeing it possible in this implementation.
Aug
21
comment Python, launch concurrent.futures.ProcessPoolExecutor with initialization?
Thanks for the info.
Aug
21
revised Python, launch concurrent.futures.ProcessPoolExecutor with initialization?
added 127 characters in body
Aug
21
comment Python, launch concurrent.futures.ProcessPoolExecutor with initialization?
Well, think of initialization as close to json.load, the 'to-be-parallelized' function is called in an iteration for many times. I don't want it to be re-initialized each time.
Aug
21
asked Python, launch concurrent.futures.ProcessPoolExecutor with initialization?
Aug
11
comment pthread_cond_wait sometimes will not receive the signal
Hello again, I noticed you used a blocking while loop to watch for work_status variable change. Is this mandatory? Won't this maxout CPU when no job is available?
Aug
11
accepted pthread_cond_wait sometimes will not receive the signal
Jul
25
awarded Autobiographer
Jul
16
comment pthread_cond_wait sometimes will not receive the signal
Thank you! I did realize it's possible the log is out of order but I didn't figure out how to keep them in sequence.
Jul
14
comment pthread_cond_wait sometimes will not receive the signal
Well, the mutex is locked prior to conditional waiting (as illustrated in td initialization). I managed to dump the return variable to the log, pthread_cond_wait always returns zero.
Jul
13
comment pthread_cond_wait sometimes will not receive the signal
Thanks but I believe I got all those points correctly. 1), if you check my initialization code of td, the mutex is locked. 2), I can't do while(flag) and condition waiting at the same time. They are separate problems aren't they? My current situation is that the waiting won't return. 3), I've got separate cond and mutex for each thread. 4), the thread is waiting on cond as thread_worker illustrated.
Jul
13
comment pthread_cond_wait sometimes will not receive the signal
@pilcrow, thanks but could you elaborate? The documentation of pthread_cond_wait clearly says that the mutex has to be locked before calling. What's an associated predicate? I understand I'm not checking the return variable, but it's not the problem I'm facing, I mean, it didn't return and kept on waiting.
Jul
13
asked pthread_cond_wait sometimes will not receive the signal
Jul
10
awarded Popular Question
Jun
25
awarded Citizen Patrol
1 2 3 4 5