Files
sdk/runtime/bin/thread_linux.h
T
Alexander Aprelev d2bc055651 [vm/shared] Add 'dart:concurrent' core library.
This brings Mutex and ConditionVariable classes to guard access to shared variables.

TEST=shared_test, shared_primitives_test
BUG=https://github.com/dart-lang/sdk/issues/55991
CoreLibraryReviewExempt: dart:concurrent library is experimental, restricted to main/dev channels, vm-only at this point.
Change-Id: I64ca7a0434cbe0079976133ccbf9de2dd4c0d7b1
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/372181
Commit-Queue: Alexander Aprelev <aam@google.com>
Reviewed-by: Slava Egorov <vegorov@google.com>
2024-07-10 19:45:29 +00:00

73 lines
1.5 KiB
C++

// Copyright (c) 2012, 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 RUNTIME_BIN_THREAD_LINUX_H_
#define RUNTIME_BIN_THREAD_LINUX_H_
#if !defined(RUNTIME_BIN_THREAD_H_)
#error Do not include thread_linux.h directly; use thread.h instead.
#endif
#include <pthread.h>
#include "platform/assert.h"
#include "platform/globals.h"
namespace dart {
namespace bin {
typedef pthread_t ThreadId;
class MutexData {
private:
MutexData() {}
~MutexData() {}
pthread_mutex_t* mutex() { return &mutex_; }
pthread_mutex_t mutex_;
friend class Mutex;
friend class ConditionVariable;
DISALLOW_ALLOCATION();
DISALLOW_COPY_AND_ASSIGN(MutexData);
};
class ConditionVariableData {
private:
ConditionVariableData() {}
~ConditionVariableData() {}
pthread_cond_t* cond() { return &cond_; }
pthread_cond_t cond_;
friend class ConditionVariable;
DISALLOW_ALLOCATION();
DISALLOW_COPY_AND_ASSIGN(ConditionVariableData);
};
class MonitorData {
private:
MonitorData() {}
~MonitorData() {}
pthread_mutex_t* mutex() { return &mutex_; }
pthread_cond_t* cond() { return &cond_; }
pthread_mutex_t mutex_;
pthread_cond_t cond_;
friend class Monitor;
DISALLOW_ALLOCATION();
DISALLOW_COPY_AND_ASSIGN(MonitorData);
};
} // namespace bin
} // namespace dart
#endif // RUNTIME_BIN_THREAD_LINUX_H_