ipc/chromium/src/base/thread_local_posix.cc

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/ipc/chromium/src/base/thread_local_posix.cc	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,36 @@
     1.4 +// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#include "base/thread_local.h"
     1.9 +
    1.10 +#include <pthread.h>
    1.11 +
    1.12 +#include "base/logging.h"
    1.13 +
    1.14 +namespace base {
    1.15 +
    1.16 +// static
    1.17 +void ThreadLocalPlatform::AllocateSlot(SlotType& slot) {
    1.18 +  int error = pthread_key_create(&slot, NULL);
    1.19 +  CHECK(error == 0);
    1.20 +}
    1.21 +
    1.22 +// static
    1.23 +void ThreadLocalPlatform::FreeSlot(SlotType& slot) {
    1.24 +  int error = pthread_key_delete(slot);
    1.25 +  DCHECK(error == 0);
    1.26 +}
    1.27 +
    1.28 +// static
    1.29 +void* ThreadLocalPlatform::GetValueFromSlot(SlotType& slot) {
    1.30 +  return pthread_getspecific(slot);
    1.31 +}
    1.32 +
    1.33 +// static
    1.34 +void ThreadLocalPlatform::SetValueInSlot(SlotType& slot, void* value) {
    1.35 +  int error = pthread_setspecific(slot, value);
    1.36 +  CHECK(error == 0);
    1.37 +}
    1.38 +
    1.39 +}  // namespace base

mercurial