This source file includes following definitions.
- AllocateSlot
- FreeSlot
- GetValueFromSlot
- SetValueInSlot
#include "mojo/public/cpp/utility/lib/thread_local.h"
#include <assert.h>
namespace mojo {
namespace internal {
void ThreadLocalPlatform::AllocateSlot(SlotType* slot) {
if (pthread_key_create(slot, NULL) != 0) {
assert(false);
}
}
void ThreadLocalPlatform::FreeSlot(SlotType slot) {
if (pthread_key_delete(slot) != 0) {
assert(false);
}
}
void* ThreadLocalPlatform::GetValueFromSlot(SlotType slot) {
return pthread_getspecific(slot);
}
void ThreadLocalPlatform::SetValueInSlot(SlotType slot, void* value) {
if (pthread_setspecific(slot, value) != 0) {
assert(false);
}
}
}
}