New answers tagged

1 vote

Portable periodic/one-shot timer thread - follow-up

It would have been nice to have an example program to experiment with. I don't like the mix of durations and bare numbers (milliseconds) in the interface (or in the implementation, but that's a ...
Toby Speight's user avatar
  • 74.9k
1 vote

Rust publish/subscribe channel library

I've found your crate looking for existing pub-sub solutions. Time has passed and there is now a good choice. async-broadcast lists a few. Review their comparisons to others. There are some situations ...
Robert Cutajar's user avatar
3 votes

Portable periodic/one-shot timer thread - follow-up

I have spotted one more scenario for deadlock in addition to calling clear from the timer. This scenario arises when the conditional wait timer is last one. In this case, the lock obtained by timer....
Vinod Kumar Singh's user avatar
5 votes
Accepted

Multithreading message queue system

Use wait() with a predicate I recommend that you always pass a predicate to wait() that checks whether the condition you are ...
G. Sliepen's user avatar
  • 55.4k
2 votes

Time based cache for single element

Duration One small issue… You pass around your time to expire as a a mere long for a count of milliseconds. But we have a class ...
Basil Bourque's user avatar
2 votes

PasteBin API scraper for new public pastes that appear at regular intervals

There is no need to initialize an array to an empty list when declaring the variable: my @flaggedRegex = (); This is simpler and cleaner: ...
toolic's user avatar
  • 3,071
2 votes
Accepted

Multi-threaded Error Handling Data Fetching Script

Exception Handling: The current exception handling is quite broad (except:). It is worse than broad in the main block, it is nonexistent since you are swallowing all exceptions, making your program ...
Kate's user avatar
  • 6,510
5 votes

Time based cache for single element

Ok, I have had a few cups of coffee now. :) For documenting tread safety, the following is quite common: /** * This class is thread safe. */ In addition to that, ...
TorbenPutkonen's user avatar
2 votes

Time based cache for single element

I see no major issues here. It's fine code. I do notice that, since the expiration time counts from when the task begins, and since there is no check for time taken between waiting for the value and ...
Sara J's user avatar
  • 3,422
6 votes

Generic multithreading solution for improving the performance of slow tasks

Not a full review of the correctness of your multi-threading code, but some initial thoughts on the algorithm design. Your Example Doesn’t Compile I don’t think a review of it is the main point of ...
Davislor's user avatar
  • 7,371
8 votes
Accepted

Generic multithreading solution for improving the performance of slow tasks

Use worker threads that pick jobs themselves There are a few issues with your code. First, you call std::async() once for every job. With most implementations of ...
G. Sliepen's user avatar
  • 55.4k

Top 50 recent answers are included