Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: test/cctest/test-lock.cc

Issue 48123: Added a wait with timeout to the platform semaphore class (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/platform-win32.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // 2 //
3 // Tests of the TokenLock class from lock.h 3 // Tests of the TokenLock class from lock.h
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include "v8.h" 7 #include "v8.h"
8 8
9 #include "platform.h" 9 #include "platform.h"
10 #include "cctest.h" 10 #include "cctest.h"
(...skipping 20 matching lines...) Expand all
31 31
32 32
33 TEST(ShallowLock) { 33 TEST(ShallowLock) {
34 Mutex* mutex = OS::CreateMutex(); 34 Mutex* mutex = OS::CreateMutex();
35 CHECK_EQ(0, mutex->Lock()); 35 CHECK_EQ(0, mutex->Lock());
36 CHECK_EQ(0, mutex->Unlock()); 36 CHECK_EQ(0, mutex->Unlock());
37 CHECK_EQ(0, mutex->Lock()); 37 CHECK_EQ(0, mutex->Lock());
38 CHECK_EQ(0, mutex->Unlock()); 38 CHECK_EQ(0, mutex->Unlock());
39 delete mutex; 39 delete mutex;
40 } 40 }
41
42
43 TEST(SemaphoreTimeout) {
44 bool ok;
45 Semaphore* sem = OS::CreateSemaphore(0);
46
47 // Semaphore not signalled - timeout.
48 ok = sem->Wait(0);
49 CHECK(!ok);
50 ok = sem->Wait(100);
51 CHECK(!ok);
52 ok = sem->Wait(1000);
53 CHECK(!ok);
54
55 // Semaphore signalled - no timeout.
56 sem->Signal();
57 ok = sem->Wait(0);
58 sem->Signal();
59 ok = sem->Wait(100);
60 sem->Signal();
61 ok = sem->Wait(1000);
62 CHECK(ok);
63 }
OLDNEW
« no previous file with comments | « src/platform-win32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698