Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Issue 10026001: Cross-platform thread primitives (Closed)

Created:
March 29, 2013, 5:26 a.m. by Felix Dahlke
Modified:
Nov. 12, 2013, 10:09 a.m.
Visibility:
Public.

Description

I've added some thread primitives (threads, mutices and condition variables) we'll need for moving JS execution to a separate thread. I'm not a fan of adding something we don't use yet, but I'm quite certain we'll need this. The alternative would be using an event loop library like libevent, which I looked into yesterday, but I don't think it's the way to go for us, at least not yet. I wasn't able to run the tests on Windows, as that's not yet possible there. I already pushed the changes as they're not used yet, and to compile them on Windows. As for the design, I've considered making something more similar to C++11's std::thread, but that isn't really usable without a general purpose functor, so I went with an inheritance-based approach.

Patch Set 1 #

Total comments: 28

Patch Set 2 : Renamed thread to nativeThread, made the tests more robust #

Patch Set 3 : Don't unlock/signal mutices/conditions, move Mutex and Condition to the top level #

Total comments: 8

Patch Set 4 : Improve mutex test #

Unified diffs Side-by-side diffs Delta from patch set Stats (+11 lines, -9 lines) Patch
M test/Thread.cpp View 1 2 3 2 chunks +11 lines, -9 lines 0 comments Download

Messages

Total messages: 8
Felix Dahlke
March 29, 2013, 6:10 a.m. (2013-03-29 06:10:55 UTC) #1
Wladimir Palant
http://codereview.adblockplus.org/10026001/diff/1/src/Thread.cpp File src/Thread.cpp (right): http://codereview.adblockplus.org/10026001/diff/1/src/Thread.cpp#newcode24 src/Thread.cpp:24: Unlock(); That's a race condition - you unlock the ...
April 3, 2013, 1:14 p.m. (2013-04-03 13:14:47 UTC) #2
Felix Dahlke
http://codereview.adblockplus.org/10026001/diff/1/src/Thread.cpp File src/Thread.cpp (right): http://codereview.adblockplus.org/10026001/diff/1/src/Thread.cpp#newcode24 src/Thread.cpp:24: Unlock(); On 2013/04/03 13:14:47, Wladimir Palant wrote: > That's ...
April 3, 2013, 4:27 p.m. (2013-04-03 16:27:59 UTC) #3
Wladimir Palant
http://codereview.adblockplus.org/10026001/diff/1/src/Thread.cpp File src/Thread.cpp (right): http://codereview.adblockplus.org/10026001/diff/1/src/Thread.cpp#newcode24 src/Thread.cpp:24: Unlock(); To me it sounds like AutoLock is a ...
April 3, 2013, 7:30 p.m. (2013-04-03 19:30:16 UTC) #4
Felix Dahlke
http://codereview.adblockplus.org/10026001/diff/1/src/Thread.cpp File src/Thread.cpp (right): http://codereview.adblockplus.org/10026001/diff/1/src/Thread.cpp#newcode24 src/Thread.cpp:24: Unlock(); On 2013/04/03 19:30:16, Wladimir Palant wrote: > To ...
April 4, 2013, 2:52 a.m. (2013-04-04 02:52:57 UTC) #5
Wladimir Palant
http://codereview.adblockplus.org/10026001/diff/12001/test/Thread.cpp File test/Thread.cpp (right): http://codereview.adblockplus.org/10026001/diff/12001/test/Thread.cpp#newcode28 test/Thread.cpp:28: Sleep(5); Why is this necessary? Seems random. http://codereview.adblockplus.org/10026001/diff/12001/test/Thread.cpp#newcode112 test/Thread.cpp:112: ...
April 4, 2013, 7:09 a.m. (2013-04-04 07:09:00 UTC) #6
Felix Dahlke
http://codereview.adblockplus.org/10026001/diff/12001/test/Thread.cpp File test/Thread.cpp (right): http://codereview.adblockplus.org/10026001/diff/12001/test/Thread.cpp#newcode28 test/Thread.cpp:28: Sleep(5); On 2013/04/04 07:09:00, Wladimir Palant wrote: > Why ...
April 4, 2013, 7:27 a.m. (2013-04-04 07:27:39 UTC) #7
Wladimir Palant
April 4, 2013, 9:26 a.m. (2013-04-04 09:26:53 UTC) #8
LGTM with that compile issue fixed.

http://codereview.adblockplus.org/10026001/diff/12001/test/Thread.cpp
File test/Thread.cpp (right):

http://codereview.adblockplus.org/10026001/diff/12001/test/Thread.cpp#newcode112
test/Thread.cpp:112: mock.mutex.Lock();
Oh well :-(

http://codereview.adblockplus.org/10026001/diff/12001/test/Thread.cpp#newcode146
test/Thread.cpp:146: ASSERT_EQ(0, queue.size());
This fails to compile for me once again, 0u please.

Powered by Google App Engine
This is Rietveld