multithreading

std::thread increses DLL reference count, which prevents the unloading of the DLL

北城以北 提交于 2021-01-29 04:35:01
问题 I have a windows c++ dll which gets loaded by a third party program. I recently added a thread pool (this one https://github.com/progschj/ThreadPool/blob/master/ThreadPool.h). But now the dll get no longer unloaded when the third party program no longer needs it. The reason is that every thread spawned in the thread pool increases the dll reference count by one. One problem is that I don't know when the third party program no longer needs the dll, so I can't manually shutdown the thread pool

Scavenger: Allocation failed - JavaScript heap out of memory

蓝咒 提交于 2021-01-29 04:31:02
问题 Here's the error message: <--- Last few GCs ---> [2383:0x7efe08001450] 6100 ms: Scavenge 30.3 (39.5) -> 30.5 (42.7) MB, 73.5 / 0.0 ms (average mu = 1.000, curr ent mu = 1.000) allocation failure [2383:0x7efe08001450] 8464 ms: Scavenge 35.1 (44.5) -> 35.3 (44.8) MB, 2336.2 / 0.0 ms (average mu = 1.000, cu rrent mu = 1.000) allocation failure [2383:0x7efe08001450] 32349 ms: Scavenge 36.1 (44.8) -> 36.0 (45.8) MB, 23879.5 / 0.2 ms (average mu = 1.000, c urrent mu = 1.000) allocation failure <---

Python using threading.Event()

一笑奈何 提交于 2021-01-29 03:35:43
问题 I have two threads that are accessing a web service. One thread is updating a resource and other is possibly getting them. My webservice class looks below: class WebServiceHandler(object): RESOURCE_URL='/Resource/{0}' def __init__(self, host, port): self._http_connection = httplib.HTTPSConnection(host, port) def update(self, id, resource): url = self.RESOURCE_URL.format(id) self._http_connection.request('POST', url, resource) response = self._http_connection.getresponse() response_body =

User-level threads for threading

半世苍凉 提交于 2021-01-29 03:11:04
问题 From the Tanenbaum OS book it is mentioned the following: "in user level threads, if a thread starts running, no other thread in that process will ever run unless the first thread voluntarily gives up the CPU". That means threads are going to run one after the other (sequently) not in parallel. So what is the advantage of the user-level threads? 回答1: There are two concepts of multitasking in a single process multiple thread environment. A single thread execute in time slice of the process.

Python loop in a coroutine [closed]

╄→尐↘猪︶ㄣ 提交于 2021-01-29 02:54:23
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 8 years ago . I've read all the documentation on the subject, but it seems I can't grasp the whole concept of Python coroutines well enough to implement what I want to do. I have a background task (which generates some random

Drawing in the Background

和自甴很熟 提交于 2021-01-29 02:40:56
问题 I have an IOS application that needs to update a view in response to either user or external events. The drawing time can be either very short or very long (several seconds) depending upon what is in the view. Right now, the drawing takes place in the drawRect method for the view When the drawing is long and there is a lot of user interaction the app becomes unresponsive. When it needs updating, the entire view needs to be updated. If a change comes in the middle of drawing, it would make

Java associate object with each thread in Executor

房东的猫 提交于 2021-01-29 02:13:41
问题 I have a bunch of runnables that I want to execute via a thread pool. However, each runnable also writes some result to some file. So right now, the runnable's interface is simple: class MyRunnable implements Runnable { ... MyRunnable(BufferedWriter writer, Task t) { this.writer = writer; this.task = t; } public void run() { ... this.writer.write(SOME_DATA); } } However, what I want is to associate one BufferedWriter (in other words, one output file) with each of the thread in the Executor

Java associate object with each thread in Executor

偶尔善良 提交于 2021-01-29 02:08:39
问题 I have a bunch of runnables that I want to execute via a thread pool. However, each runnable also writes some result to some file. So right now, the runnable's interface is simple: class MyRunnable implements Runnable { ... MyRunnable(BufferedWriter writer, Task t) { this.writer = writer; this.task = t; } public void run() { ... this.writer.write(SOME_DATA); } } However, what I want is to associate one BufferedWriter (in other words, one output file) with each of the thread in the Executor

Java associate object with each thread in Executor

≡放荡痞女 提交于 2021-01-29 02:07:54
问题 I have a bunch of runnables that I want to execute via a thread pool. However, each runnable also writes some result to some file. So right now, the runnable's interface is simple: class MyRunnable implements Runnable { ... MyRunnable(BufferedWriter writer, Task t) { this.writer = writer; this.task = t; } public void run() { ... this.writer.write(SOME_DATA); } } However, what I want is to associate one BufferedWriter (in other words, one output file) with each of the thread in the Executor

threading module's reference not removed by gc

两盒软妹~` 提交于 2021-01-29 00:45:04
问题 I found gc doesn't remove the objects created from Threading.thread() . # print memory status every 5sec def trace_memory(): while True: time.sleep(5) print(mem_top()) # just print and end def test_thread(): print('thread') threading.Thread(target=trace_memory).start() curr_count = 0 max_count = 10000 while max_count > curr_count: threading.Thread(target=test_thread).start() curr_count += 1 and below is result of mem_top() : refs: 10001 <class 'list'> [<unlocked _thread.lock object at