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

Side by Side Diff: Source/wtf/ThreadingPthreads.cpp

Issue 20300002: Fix trailing whitespace in .cpp, .h, and .idl files (ex. Source/core) (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 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 | « Source/wtf/ThreadingPrimitives.h ('k') | Source/wtf/ThreadingWin.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com) 3 * Copyright (C) 2007 Justin Haygood (jhaygood@reaktix.com)
4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of 15 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
16 * its contributors may be used to endorse or promote products derived 16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission. 17 * from this software without specific prior written permission.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 #endif 60 #endif
61 61
62 namespace WTF { 62 namespace WTF {
63 63
64 class PthreadState { 64 class PthreadState {
65 WTF_MAKE_FAST_ALLOCATED; 65 WTF_MAKE_FAST_ALLOCATED;
66 public: 66 public:
67 enum JoinableState { 67 enum JoinableState {
68 Joinable, // The default thread state. The thread can be joined on. 68 Joinable, // The default thread state. The thread can be joined on.
69 69
70 Joined, // Somebody waited on this thread to exit and this thread finall y exited. This state is here because there can be a 70 Joined, // Somebody waited on this thread to exit and this thread finall y exited. This state is here because there can be a
71 // period of time between when the thread exits (which causes pt hread_join to return and the remainder of waitOnThreadCompletion to run) 71 // period of time between when the thread exits (which causes pt hread_join to return and the remainder of waitOnThreadCompletion to run)
72 // and when threadDidExit is called. We need threadDidExit to ta ke charge and delete the thread data since there's 72 // and when threadDidExit is called. We need threadDidExit to ta ke charge and delete the thread data since there's
73 // nobody else to pick up the slack in this case (since waitOnTh readCompletion has already returned). 73 // nobody else to pick up the slack in this case (since waitOnTh readCompletion has already returned).
74 74
75 Detached // The thread has been detached and can no longer be joined on. At this point, the thread must take care of cleaning up after itself. 75 Detached // The thread has been detached and can no longer be joined on. At this point, the thread must take care of cleaning up after itself.
76 }; 76 };
77 77
78 // Currently all threads created by WTF start out as joinable. 78 // Currently all threads created by WTF start out as joinable.
79 PthreadState(pthread_t handle) 79 PthreadState(pthread_t handle)
80 : m_joinableState(Joinable) 80 : m_joinableState(Joinable)
81 , m_didExit(false) 81 , m_didExit(false)
82 , m_pthreadHandle(handle) 82 , m_pthreadHandle(handle)
83 { 83 {
84 } 84 }
85 85
86 JoinableState joinableState() { return m_joinableState; } 86 JoinableState joinableState() { return m_joinableState; }
87 pthread_t pthreadHandle() { return m_pthreadHandle; } 87 pthread_t pthreadHandle() { return m_pthreadHandle; }
88 void didBecomeDetached() { m_joinableState = Detached; } 88 void didBecomeDetached() { m_joinableState = Detached; }
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 threadMap().remove(threadID); 268 threadMap().remove(threadID);
269 else 269 else
270 threadMap().get(threadID)->didBecomeDetached(); 270 threadMap().get(threadID)->didBecomeDetached();
271 } 271 }
272 272
273 void threadDidExit(ThreadIdentifier threadID) 273 void threadDidExit(ThreadIdentifier threadID)
274 { 274 {
275 MutexLocker locker(threadMapMutex()); 275 MutexLocker locker(threadMapMutex());
276 PthreadState* state = threadMap().get(threadID); 276 PthreadState* state = threadMap().get(threadID);
277 ASSERT(state); 277 ASSERT(state);
278 278
279 state->didExit(); 279 state->didExit();
280 280
281 if (state->joinableState() != PthreadState::Joinable) 281 if (state->joinableState() != PthreadState::Joinable)
282 threadMap().remove(threadID); 282 threadMap().remove(threadID);
283 } 283 }
284 284
285 void yield() 285 void yield()
286 { 286 {
287 sched_yield(); 287 sched_yield();
288 } 288 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 return false; 336 return false;
337 } 337 }
338 338
339 void Mutex::unlock() 339 void Mutex::unlock()
340 { 340 {
341 int result = pthread_mutex_unlock(&m_mutex); 341 int result = pthread_mutex_unlock(&m_mutex);
342 ASSERT_UNUSED(result, !result); 342 ASSERT_UNUSED(result, !result);
343 } 343 }
344 344
345 ThreadCondition::ThreadCondition() 345 ThreadCondition::ThreadCondition()
346 { 346 {
347 pthread_cond_init(&m_condition, NULL); 347 pthread_cond_init(&m_condition, NULL);
348 } 348 }
349 349
350 ThreadCondition::~ThreadCondition() 350 ThreadCondition::~ThreadCondition()
351 { 351 {
352 pthread_cond_destroy(&m_condition); 352 pthread_cond_destroy(&m_condition);
353 } 353 }
354 354
355 void ThreadCondition::wait(Mutex& mutex) 355 void ThreadCondition::wait(Mutex& mutex)
356 { 356 {
357 int result = pthread_cond_wait(&m_condition, &mutex.impl()); 357 int result = pthread_cond_wait(&m_condition, &mutex.impl());
358 ASSERT_UNUSED(result, !result); 358 ASSERT_UNUSED(result, !result);
359 } 359 }
360 360
361 bool ThreadCondition::timedWait(Mutex& mutex, double absoluteTime) 361 bool ThreadCondition::timedWait(Mutex& mutex, double absoluteTime)
362 { 362 {
363 if (absoluteTime < currentTime()) 363 if (absoluteTime < currentTime())
364 return false; 364 return false;
(...skipping 21 matching lines...) Expand all
386 386
387 void ThreadCondition::broadcast() 387 void ThreadCondition::broadcast()
388 { 388 {
389 int result = pthread_cond_broadcast(&m_condition); 389 int result = pthread_cond_broadcast(&m_condition);
390 ASSERT_UNUSED(result, !result); 390 ASSERT_UNUSED(result, !result);
391 } 391 }
392 392
393 } // namespace WTF 393 } // namespace WTF
394 394
395 #endif // USE(PTHREADS) 395 #endif // USE(PTHREADS)
OLDNEW
« no previous file with comments | « Source/wtf/ThreadingPrimitives.h ('k') | Source/wtf/ThreadingWin.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698