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

Side by Side Diff: ppapi/utility/threading/simple_thread.h

Issue 12259018: Provide alternate constructor for specifying a simple thread's stacksize. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 10 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 | « no previous file | ppapi/utility/threading/simple_thread.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef PPAPI_UTILITY_THREADING_SIMPLE_THREAD_H_ 5 #ifndef PPAPI_UTILITY_THREADING_SIMPLE_THREAD_H_
6 #define PPAPI_UTILITY_THREADING_SIMPLE_THREAD_H_ 6 #define PPAPI_UTILITY_THREADING_SIMPLE_THREAD_H_
7 7
8 #ifdef WIN32 8 #ifdef WIN32
9 #include <windows.h> 9 #include <windows.h>
10 #else 10 #else
(...skipping 11 matching lines...) Expand all
22 public: 22 public:
23 #ifdef WIN32 23 #ifdef WIN32
24 typedef HANDLE ThreadHandle; 24 typedef HANDLE ThreadHandle;
25 #else 25 #else
26 typedef pthread_t ThreadHandle; 26 typedef pthread_t ThreadHandle;
27 #endif 27 #endif
28 28
29 typedef void (*ThreadFunc)(MessageLoop&, void* user_data); 29 typedef void (*ThreadFunc)(MessageLoop&, void* user_data);
30 30
31 explicit SimpleThread(const InstanceHandle& instance); 31 explicit SimpleThread(const InstanceHandle& instance);
32 explicit SimpleThread(const InstanceHandle& instance, const size_t stacksize);
brettw 2013/02/16 04:19:40 I'd remove "const" for the argument here.
nfullagar1 2013/02/19 18:59:10 Done.
32 ~SimpleThread(); 33 ~SimpleThread();
33 34
34 // Starts a thread and runs a message loop in it. If you need control over 35 // Starts a thread and runs a message loop in it. If you need control over
35 // how the message loop is run, use StartWithFunction. Returns true on 36 // how the message loop is run, use StartWithFunction. Returns true on
36 // success, false if the thread is already running or couldn't be started. 37 // success, false if the thread is already running or couldn't be started.
37 bool Start(); 38 bool Start();
38 39
39 // Posts a quit message to the message loop and blocks until the thread 40 // Posts a quit message to the message loop and blocks until the thread
40 // exits. Returns true on success. If the thread is not running, returns 41 // exits. Returns true on success. If the thread is not running, returns
41 // false. 42 // false.
42 bool Join(); 43 bool Join();
43 44
44 // Normally you can just use Start() to start a thread, and then post work to 45 // Normally you can just use Start() to start a thread, and then post work to
45 // it. In some cases you will want control over the message. If ThreadFunc 46 // it. In some cases you will want control over the message. If ThreadFunc
46 // is NULL, this acts the same as Start(). 47 // is NULL, this acts the same as Start().
47 bool StartWithFunction(ThreadFunc func, void* user_data); 48 bool StartWithFunction(ThreadFunc func, void* user_data);
48 49
49 MessageLoop& message_loop() { return message_loop_; } 50 MessageLoop& message_loop() { return message_loop_; }
50 ThreadHandle thread() const { return thread_; } 51 ThreadHandle thread() const { return thread_; }
51 52
52 private: 53 private:
53 InstanceHandle instance_; 54 InstanceHandle instance_;
54 MessageLoop message_loop_; 55 MessageLoop message_loop_;
55 56 const size_t stacksize_;
56 ThreadHandle thread_; 57 ThreadHandle thread_;
57 58
58 // Disallow (not implemented). 59 // Disallow (not implemented).
59 SimpleThread(const SimpleThread&); 60 SimpleThread(const SimpleThread&);
61 SimpleThread(const SimpleThread&, const size_t stacksize);
brettw 2013/02/16 04:19:40 I'm remove "const" for the argument here.
nfullagar1 2013/02/19 18:59:10 Done.
60 SimpleThread& operator=(const SimpleThread&); 62 SimpleThread& operator=(const SimpleThread&);
61 }; 63 };
62 64
63 } // namespace pp 65 } // namespace pp
64 66
65 #endif // PPAPI_UTILITY_THREADING_SIMPLE_THREAD_H_ 67 #endif // PPAPI_UTILITY_THREADING_SIMPLE_THREAD_H_
66 68
OLDNEW
« no previous file with comments | « no previous file | ppapi/utility/threading/simple_thread.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698