Files
sdk/runtime/vm/thread.h
T
koda@google.com 280dc6fbd4 Introduce simple Thread class to support gradual refactoring of interfaces.
This first iteration of Thread just forwards a subset of the BaseIsolate methods.

The plan is to first add Thread/Zone-based interfaces where appropriate, deprecate their Isolate-based versions, and finally remove them once all callsites have been migrated.

This CL only demonstrates a small part of this migration, for BitVector and some of the compiler classes. There are thousands of additional call-sites that will need to be updated.

R=asiva@google.com

Review URL: https://codereview.chromium.org//850183005

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@43073 260f80e4-7a28-3924-810f-c04153c831b5
2015-01-22 14:14:16 +00:00

41 lines
1.1 KiB
C++

// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef VM_THREAD_H_
#define VM_THREAD_H_
#include "vm/isolate.h"
namespace dart {
// A VM thread; may be executing Dart code or performing helper tasks like
// garbage collection.
class Thread {
public:
static Thread* Current() {
// For now, there is still just one thread per isolate, and the Thread
// class just aliases the Isolate*. Once all interfaces and uses have been
// updated to distinguish between isolates and threads, Thread will get its
// own thread-local storage key.
return reinterpret_cast<Thread*>(Isolate::Current());
}
// The topmost zone used for allocation in this thread.
Zone* zone() {
return reinterpret_cast<BaseIsolate*>(this)->current_zone();
}
// The isolate that this thread is operating on.
Isolate* isolate() {
return reinterpret_cast<Isolate*>(this);
}
private:
DISALLOW_COPY_AND_ASSIGN(Thread);
};
} // namespace dart
#endif // VM_THREAD_H_