multithreading

How do you detect that a TEvent has been set?

让人想犯罪 __ 提交于 2021-01-27 02:12:14
问题 The Delphi XE2 documentation says this about TEvent: Sometimes, you need to wait for a thread to finish some operation rather than waiting for a particular thread to complete execution. To do this, use an event object. Event objects (System.SyncObjs.TEvent) should be created with global scope so that they can act like signals that are visible to all threads. When a thread completes an operation that other threads depend on, it calls TEvent.SetEvent. SetEvent turns on the signal, so any other

How do you detect that a TEvent has been set?

╄→尐↘猪︶ㄣ 提交于 2021-01-27 02:11:55
问题 The Delphi XE2 documentation says this about TEvent: Sometimes, you need to wait for a thread to finish some operation rather than waiting for a particular thread to complete execution. To do this, use an event object. Event objects (System.SyncObjs.TEvent) should be created with global scope so that they can act like signals that are visible to all threads. When a thread completes an operation that other threads depend on, it calls TEvent.SetEvent. SetEvent turns on the signal, so any other

How do you detect that a TEvent has been set?

送分小仙女□ 提交于 2021-01-27 02:10:08
问题 The Delphi XE2 documentation says this about TEvent: Sometimes, you need to wait for a thread to finish some operation rather than waiting for a particular thread to complete execution. To do this, use an event object. Event objects (System.SyncObjs.TEvent) should be created with global scope so that they can act like signals that are visible to all threads. When a thread completes an operation that other threads depend on, it calls TEvent.SetEvent. SetEvent turns on the signal, so any other

How do you detect that a TEvent has been set?

倾然丶 夕夏残阳落幕 提交于 2021-01-27 02:09:24
问题 The Delphi XE2 documentation says this about TEvent: Sometimes, you need to wait for a thread to finish some operation rather than waiting for a particular thread to complete execution. To do this, use an event object. Event objects (System.SyncObjs.TEvent) should be created with global scope so that they can act like signals that are visible to all threads. When a thread completes an operation that other threads depend on, it calls TEvent.SetEvent. SetEvent turns on the signal, so any other

How to make sure that method is executed only once and from one thread only?

独自空忆成欢 提交于 2021-01-26 22:43:37
问题 I have a below method which I want to execute on below conditions: This method should be executed only once. And once it is executed, it cannot be executed again so if anyone tried to execute again, it should return back by logging some useful error message already executed or anything useful. And it should be executed by only one thread only. So if multiple threads are calling below method, then it should be called by only one thread and other threads should wait for initialization to

How to make sure that method is executed only once and from one thread only?

北城余情 提交于 2021-01-26 22:34:31
问题 I have a below method which I want to execute on below conditions: This method should be executed only once. And once it is executed, it cannot be executed again so if anyone tried to execute again, it should return back by logging some useful error message already executed or anything useful. And it should be executed by only one thread only. So if multiple threads are calling below method, then it should be called by only one thread and other threads should wait for initialization to

Is writing std::deque at different memory locations concurrently thread-safe?

浪尽此生 提交于 2021-01-26 19:33:47
问题 I have a std::deque<std::pair<CustomObj, int>> that doesn't change in size when starting the concurrent block. The concurrent block reads each CustomObj of the deque and sets the int . I can guarantee that the deque won't change size therefore it won't reallocate, and that each thread will only access a memory chunk of the deque but not the other thread's. Does it lead to undefined behaviour reading and writing concurrently? Should I put the writing and reading in a mutual exclusion zone? 回答1

Is writing std::deque at different memory locations concurrently thread-safe?

大憨熊 提交于 2021-01-26 19:31:12
问题 I have a std::deque<std::pair<CustomObj, int>> that doesn't change in size when starting the concurrent block. The concurrent block reads each CustomObj of the deque and sets the int . I can guarantee that the deque won't change size therefore it won't reallocate, and that each thread will only access a memory chunk of the deque but not the other thread's. Does it lead to undefined behaviour reading and writing concurrently? Should I put the writing and reading in a mutual exclusion zone? 回答1

System.Timers.Timer Elapsed intermittently not firing when using an Task.Run with async from Console App

给你一囗甜甜゛ 提交于 2021-01-26 13:23:49
问题 I am using a console application and I have batches of 20 URIs that I need to read from and I have found a massive speed boost by making all tasks and running them in parallel then sorting the results on completion in a different thread (allowing the next batch to be fetched). In the calls I am currently using, each thread blocks when it gets the response stream, I also see there is a async version of the same method GetResponseAsync . I understand there are benefits of freeing up the thread

System.Timers.Timer Elapsed intermittently not firing when using an Task.Run with async from Console App

孤者浪人 提交于 2021-01-26 13:23:19
问题 I am using a console application and I have batches of 20 URIs that I need to read from and I have found a massive speed boost by making all tasks and running them in parallel then sorting the results on completion in a different thread (allowing the next batch to be fetched). In the calls I am currently using, each thread blocks when it gets the response stream, I also see there is a async version of the same method GetResponseAsync . I understand there are benefits of freeing up the thread