dart-sdk/runtime/vm/isolate_linux.cc
asiva@google.com b53c955b37 - Refactor the isolate callback mechanism to also include creation of the
isolate, this enables creation of isolates using a snapshot
- remove source buffers of corelib, coreimpl-lib and builtin-lib from the binary
Review URL: http://codereview.chromium.org//8673002

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@1958 260f80e4-7a28-3924-810f-c04153c831b5
2011-12-01 00:30:25 +00:00

42 lines
1.3 KiB
C++

// Copyright (c) 2011, 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.
#include <errno.h>
#include <pthread.h>
#include "vm/assert.h"
#include "vm/isolate.h"
namespace dart {
#define VALIDATE_PTHREAD_RESULT(result) \
if (result != 0) { \
FATAL2("pthread error: %d (%s)", result, strerror(result)); \
}
// The single pthread key which stores all the thread local data for a
// thread. Since an Isolate is the central repository for storing all
// isolate specific information a single pthread key is sufficient.
pthread_key_t isolate_key = PTHREAD_KEY_UNSET;
void Isolate::SetCurrent(Isolate* current) {
ASSERT(isolate_key != PTHREAD_KEY_UNSET);
int result = pthread_setspecific(isolate_key, current);
VALIDATE_PTHREAD_RESULT(result);
}
void Isolate::InitOnce() {
ASSERT(isolate_key == PTHREAD_KEY_UNSET);
int result = pthread_key_create(&isolate_key, NULL);
// Make sure creating a key was successful.
VALIDATE_PTHREAD_RESULT(result);
ASSERT(isolate_key != PTHREAD_KEY_UNSET);
create_callback_ = NULL;
}
} // namespace dart