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

Side by Side Diff: runtime/vm/thread.h

Issue 1393423005: Add ThreadIterator for iterating over all Threads (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « no previous file | runtime/vm/thread.cc » ('j') | runtime/vm/thread.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart 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 file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_THREAD_H_ 5 #ifndef VM_THREAD_H_
6 #define VM_THREAD_H_ 6 #define VM_THREAD_H_
7 7
8 #include "vm/globals.h" 8 #include "vm/globals.h"
9 #include "vm/handles.h" 9 #include "vm/handles.h"
10 #include "vm/os_thread.h" 10 #include "vm/os_thread.h"
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 406
407 #if defined(DEBUG) 407 #if defined(DEBUG)
408 #define REUSABLE_HANDLE_SCOPE_VARIABLE(object) \ 408 #define REUSABLE_HANDLE_SCOPE_VARIABLE(object) \
409 bool reusable_##object##_handle_scope_active_; 409 bool reusable_##object##_handle_scope_active_;
410 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_VARIABLE); 410 REUSABLE_HANDLE_LIST(REUSABLE_HANDLE_SCOPE_VARIABLE);
411 #undef REUSABLE_HANDLE_SCOPE_VARIABLE 411 #undef REUSABLE_HANDLE_SCOPE_VARIABLE
412 #endif // defined(DEBUG) 412 #endif // defined(DEBUG)
413 413
414 VMHandles reusable_handles_; 414 VMHandles reusable_handles_;
415 415
416 // All |Thread|s are registered in the thread list.
417 Thread* thread_list_next_;
418
419 static Thread* thread_list_head_;
420 static Mutex thread_list_lock_;
siva 2015/10/12 23:03:14 In general we avoid declaring a static Mutex like
Cutch 2015/10/13 16:41:23 Done.
421
422 static void AddThreadToList(Thread* thread);
423 static void RemoveThreadFromList(Thread* thread);
siva 2015/10/12 23:03:14 these functions should be private functions to ens
Cutch 2015/10/13 16:41:24 These are private.
424
416 explicit Thread(bool init_vm_constants = true); 425 explicit Thread(bool init_vm_constants = true);
417 426
418 void InitVMConstants(); 427 void InitVMConstants();
419 428
420 void ClearState() { 429 void ClearState() {
421 memset(&state_, 0, sizeof(state_)); 430 memset(&state_, 0, sizeof(state_));
422 } 431 }
423 432
424 void StoreBufferRelease( 433 void StoreBufferRelease(
425 StoreBuffer::ThresholdPolicy policy = StoreBuffer::kCheckThreshold); 434 StoreBuffer::ThresholdPolicy policy = StoreBuffer::kCheckThreshold);
(...skipping 13 matching lines...) Expand all
439 void Unschedule(bool bypass_safepoint = false); 448 void Unschedule(bool bypass_safepoint = false);
440 449
441 #define REUSABLE_FRIEND_DECLARATION(name) \ 450 #define REUSABLE_FRIEND_DECLARATION(name) \
442 friend class Reusable##name##HandleScope; 451 friend class Reusable##name##HandleScope;
443 REUSABLE_HANDLE_LIST(REUSABLE_FRIEND_DECLARATION) 452 REUSABLE_HANDLE_LIST(REUSABLE_FRIEND_DECLARATION)
444 #undef REUSABLE_FRIEND_DECLARATION 453 #undef REUSABLE_FRIEND_DECLARATION
445 454
446 friend class ApiZone; 455 friend class ApiZone;
447 friend class Isolate; 456 friend class Isolate;
448 friend class StackZone; 457 friend class StackZone;
458 friend class ThreadIterator;
459 friend class ThreadIteratorTestHelper;
449 friend class ThreadRegistry; 460 friend class ThreadRegistry;
461
450 DISALLOW_COPY_AND_ASSIGN(Thread); 462 DISALLOW_COPY_AND_ASSIGN(Thread);
451 }; 463 };
452 464
465
466 // Note that this takes the thread list lock, prohibiting threads from coming
467 // on- or off-line.
468 class ThreadIterator : public ValueObject {
469 public:
470 ThreadIterator();
471 ~ThreadIterator();
472
473 // Returns false when there are no more threads left.
474 bool HasNext();
siva 2015/10/12 23:03:14 bool HasNext() const;
Cutch 2015/10/13 16:41:24 Done.
475
476 // Returns the current thread and moves forward.
477 Thread* Next();
478
479 private:
480 Thread* next_;
481 };
482
453 } // namespace dart 483 } // namespace dart
454 484
455 #endif // VM_THREAD_H_ 485 #endif // VM_THREAD_H_
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/thread.cc » ('j') | runtime/vm/thread.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698