ipc/chromium/src/base/thread_local_win.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_win.cc	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,38 @@
     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 <windows.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 +  slot = TlsAlloc();
    1.19 +  CHECK(slot != TLS_OUT_OF_INDEXES);
    1.20 +}
    1.21 +
    1.22 +// static
    1.23 +void ThreadLocalPlatform::FreeSlot(SlotType& slot) {
    1.24 +  if (!TlsFree(slot)) {
    1.25 +    NOTREACHED() << "Failed to deallocate tls slot with TlsFree().";
    1.26 +  }
    1.27 +}
    1.28 +
    1.29 +// static
    1.30 +void* ThreadLocalPlatform::GetValueFromSlot(SlotType& slot) {
    1.31 +  return TlsGetValue(slot);
    1.32 +}
    1.33 +
    1.34 +// static
    1.35 +void ThreadLocalPlatform::SetValueInSlot(SlotType& slot, void* value) {
    1.36 +  if (!TlsSetValue(slot, value)) {
    1.37 +    CHECK(false) << "Failed to TlsSetValue().";
    1.38 +  }
    1.39 +}
    1.40 +
    1.41 +}  // namespace base

mercurial