73c2a13913
This the initial commit for adding a thread pool to the Dart server. For now it is hidden behind a flag (--enable_thread_pool) and when enabled just starts up and processes 100 void tasks. Mac OS implementation is not tested and Windows implementation is still pending. As we are currently not sharing anything between bin/ and vm/ I have just used pthread calls directly in the Linux and Mac OS implementation code. However with Monitor and Thread classes from vm/ the thread pool could be written platform independently. This can always be changed later. R=ager@google.com BUG= TEST= Review URL: http://codereview.chromium.org//8983017 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@2946 260f80e4-7a28-3924-810f-c04153c831b5
48 lines
999 B
C++
48 lines
999 B
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 BIN_THREAD_POOL_LINUX_H_
|
|
#define BIN_THREAD_POOL_LINUX_H_
|
|
|
|
#include <pthread.h>
|
|
|
|
#include "vm/globals.h"
|
|
|
|
|
|
class TaskQueueData {
|
|
private:
|
|
TaskQueueData() {}
|
|
~TaskQueueData() {}
|
|
|
|
pthread_mutex_t* mutex() { return &mutex_; }
|
|
pthread_cond_t* cond() { return &cond_; }
|
|
|
|
pthread_mutex_t mutex_;
|
|
pthread_cond_t cond_;
|
|
|
|
friend class TaskQueue;
|
|
|
|
DISALLOW_ALLOCATION();
|
|
DISALLOW_COPY_AND_ASSIGN(TaskQueueData);
|
|
};
|
|
|
|
|
|
class ThreadPoolData {
|
|
private:
|
|
ThreadPoolData() {}
|
|
~ThreadPoolData() {}
|
|
|
|
pthread_t* threads() { return threads_; }
|
|
void set_threads(pthread_t* threads) { threads_ = threads; }
|
|
|
|
pthread_t* threads_;
|
|
|
|
friend class ThreadPool;
|
|
|
|
DISALLOW_ALLOCATION();
|
|
DISALLOW_COPY_AND_ASSIGN(ThreadPoolData);
|
|
};
|
|
|
|
#endif // BIN_THREAD_POOL_LINUX_H_
|