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

Side by Side Diff: src/vm/process_handle.h

Issue 1405293007: Bugfix in process handle: Do detaching from owner process separately from derefing. (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « src/vm/process.cc ('k') | src/vm/refcounted.h » ('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) 2015, the Fletch project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Fletch project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 #ifndef SRC_VM_PROCESS_HANDLE_H_ 5 #ifndef SRC_VM_PROCESS_HANDLE_H_
6 #define SRC_VM_PROCESS_HANDLE_H_ 6 #define SRC_VM_PROCESS_HANDLE_H_
7 7
8 #include "src/shared/platform.h" 8 #include "src/shared/platform.h"
9 9
10 #include "src/vm/spinlock.h" 10 #include "src/vm/spinlock.h"
11 #include "src/vm/refcounted.h" 11 #include "src/vm/refcounted.h"
12 12
13 namespace fletch { 13 namespace fletch {
14 14
15 class Process; 15 class Process;
16 16
17 class ProcessHandle : public Refcounted<ProcessHandle> { 17 class ProcessHandle : public Refcounted<ProcessHandle> {
18 public: 18 public:
19 explicit ProcessHandle(Process* process) : process_(process) {} 19 explicit ProcessHandle(Process* process) : process_(process) {}
20 20
21 Spinlock* lock() { return &spinlock_; } 21 Spinlock* lock() { return &spinlock_; }
22 22
23 Process* process() const { return process_; } 23 Process* process() const { return process_; }
24 24
25 private: 25 private:
26 friend class Process; 26 friend class Process;
27 27
28 static void OwnerProcessTerminating(ProcessHandle* handle) { 28 void OwnerProcessTerminating() {
29 handle->lock()->Lock(); 29 ScopedSpinlock locker(&spinlock_);
30 ASSERT(handle->process_ != NULL); 30 ASSERT(process_ != NULL);
31 handle->process_ = NULL; 31 process_ = NULL;
32 if (!handle->DecrementRefWithoutDelete()) {
33 handle->lock()->Unlock();
kustermann 2015/10/29 11:17:20 The DecrementRefWithoutDelete() & Unlock/Delete is
34 } else {
35 delete handle;
36 }
37 } 32 }
38 33
39 Process* process_; 34 Process* process_;
40 Spinlock spinlock_; 35 Spinlock spinlock_;
41 }; 36 };
42 37
43 } // namespace fletch 38 } // namespace fletch
44 39
45 #endif // SRC_VM_PROCESS_HANDLE_H_ 40 #endif // SRC_VM_PROCESS_HANDLE_H_
OLDNEW
« no previous file with comments | « src/vm/process.cc ('k') | src/vm/refcounted.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698