SkTLS_pthread.cpp 691 B

12345678910111213141516171819202122232425
  1. /*
  2. * Copyright 2013 Google Inc.
  3. *
  4. * Use of this source code is governed by a BSD-style license that can be
  5. * found in the LICENSE file.
  6. */
  7. #include "include/private/SkOnce.h"
  8. #include "src/core/SkTLS.h"
  9. #include <pthread.h>
  10. static pthread_key_t gSkTLSKey;
  11. void* SkTLS::PlatformGetSpecific(bool forceCreateTheSlot) {
  12. // should we use forceCreateTheSlot to potentially just return nullptr if
  13. // we've never been called with forceCreateTheSlot==true ?
  14. static SkOnce once;
  15. once(pthread_key_create, &gSkTLSKey, SkTLS::Destructor);
  16. return pthread_getspecific(gSkTLSKey);
  17. }
  18. void SkTLS::PlatformSetSpecific(void* ptr) {
  19. (void)pthread_setspecific(gSkTLSKey, ptr);
  20. }