本文整理汇总了C++中TlsGetValue函数的典型用法代码示例。如果您正苦于以下问题:C++ TlsGetValue函数的具体用法?C++ TlsGetValue怎么用?C++ TlsGetValue使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了TlsGetValue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hpgs_set_verror
/*! Set the error message of the current thread to the given string.
Always returns -1.
*/
int hpgs_set_verror(const char *fmt, va_list ap)
{
char *x;
#ifdef WIN32
x = (char *)TlsGetValue(tls_handle);
if (x) HeapFree(hHeap,0,x);
x = vsprintf_hHeap(fmt,ap);
TlsSetValue(tls_handle,x);
#else
x = (char *)pthread_getspecific (key);
if (x) free(x);
va_list aq;
va_copy(aq, ap);
x = hpgs_vsprintf_malloc(fmt,aq);
va_end(aq);
pthread_setspecific (key,x);
#endif
return -1;
}
示例2: silc_thread_self
SilcThread silc_thread_self(void)
{
#ifdef SILC_THREADS
SilcWin32Thread self = TlsGetValue(silc_thread_tls);
if (!self) {
/* This should only happen for the main thread. */
HANDLE handle = GetCurrentThread ();
HANDLE process = GetCurrentProcess ();
self = silc_calloc(1, sizeof(*self));
DuplicateHandle(process, handle, process,
&self->thread, 0, FALSE,
DUPLICATE_SAME_ACCESS);
TlsSetValue(silc_thread_tls, self);
}
return (SilcThread)self;
#else
return NULL;
#endif
}
示例3: callback_uri
int callback_uri(http_parser *parser, const char *pos, size_t len)
{
http_message *message = (http_message *) TlsGetValue(dwTlsIndex);
char uri_buf[MAX_URI_SIZE];
DWORD uri_buflen = MAX_URI_SIZE;
strncpy_s(uri_buf, MAX_URI_SIZE, pos, len);
InternetCanonicalizeUrlA(uri_buf, message->request_uri, &uri_buflen, ICU_DECODE | ICU_NO_ENCODE);
return 0;
}
示例4: BEHAVIAC_ASSERT
int ConnectorInterface::GetBufferIndex(bool bReserve)
{
#if BEHAVIAC_COMPILER_MSVC
BEHAVIAC_ASSERT(t_packetBufferIndex != TLS_OUT_OF_INDEXES);
int bufferIndex = (int)TlsGetValue(t_packetBufferIndex);
#else
BEHAVIAC_ASSERT(t_packetBufferIndex != (unsigned int) - 1);
int bufferIndex = (int)t_packetBufferIndex;
#endif
//WHEN bReserve is false, it is unsafe to allocate memory as other threads might be allocating
//you can avoid the following assert to malloc a block of memory in your thread at the very beginning
BEHAVIAC_ASSERT(bufferIndex > 0 || bReserve);
//bufferIndex initially is 0
if (bufferIndex <= 0 && bReserve)
{
bufferIndex = ReserveThreadPacketBuffer();
}
return bufferIndex;
}
示例5:
ThreadLocalStorage::~ThreadLocalStorage()
{
if (!instance)
return;
#ifdef WIN32
if (instance->cl_tls_index == TLS_OUT_OF_INDEXES)
return;
ThreadLocalStorage_Impl *tls_impl = (ThreadLocalStorage_Impl *)TlsGetValue(instance->cl_tls_index);
if (tls_impl)
tls_impl->release_reference();
#elif !defined(HAVE_TLS)
if (!instance->cl_tls_index_created)
return;
ThreadLocalStorage_Impl *tls_impl = (ThreadLocalStorage_Impl *) pthread_getspecific(instance->cl_tls_index);
if (tls_impl)
tls_impl->release_reference();
#else
if (instance->cl_tls_impl)
instance->cl_tls_impl->release_reference();
#endif
}
示例6: pthread_self
pthread_t pthread_self(void)
{
pthread_t t;
_pthread_once_raw(&_pthread_tls_once, pthread_tls_init);
t = (pthread_t)TlsGetValue(_pthread_tls);
/* Main thread? */
if (!t)
{
t = (pthread_t)malloc(sizeof(struct _pthread_v));
/* If cannot initialize main thread, then the only thing we can do is abort */
if (!t) abort();
t->ret_arg = NULL;
t->func = NULL;
t->clean = NULL;
t->cancelled = 0;
t->p_state = PTHREAD_DEFAULT_ATTR;
t->keymax = 0;
t->keyval = NULL;
t->h = GetCurrentThread();
/* Save for later */
TlsSetValue(_pthread_tls, t);
if (setjmp(t->jb))
{
/* Make sure we free ourselves if we are detached */
if (!t->h) free(t);
/* Time to die */
_endthreadex(0);
}
}
return t;
}
示例7: aboutsetmiscstring
boolean aboutsetmiscstring (bigstring bsmisc) {
#ifdef WIN95VERSION
extern DWORD ixthreadglobalsgrabcount; // Tls index of counter for nest globals grabbing
long grabcount = (long) TlsGetValue (ixthreadglobalsgrabcount);
#endif
// register hdlcancoonrecord hc = cancoonglobals;
// hdlwindowinfo hinfo;
copystring (bsmisc, bsmiscinfo);
// if (!findaboutwindow (&hinfo) || !shellpushglobals ((**hinfo).macwindow))
// return (false);
#ifdef WIN95VERSION
if (grabcount > 0)
#endif
if (aboutport != nil && flhavemiscrect) {
pushport (aboutport);
pushclip (miscinforect);
eraserect (miscinforect);
movepento (miscinforect.left, miscinforect.top + globalfontinfo.ascent);
pendrawstring (bsmisc);
popclip ();
popport ();
}
// shellpopglobals ();
return (true);
} /*aboutsetmiscstring*/
示例8: wiProcess_ThreadIndex
// ================================================================================================
// FUNCTION : wiProcess_ThreadIndex()
// ------------------------------------------------------------------------------------------------
// ================================================================================================
unsigned int wiProcess_ThreadIndex(void)
{
#ifdef WISE_BUILD_MULTITHREADED
#if defined WISE_USE_PTHREADS
{
void *lpvData = pthread_getspecific(wiProcessKey);
return lpvData ? *((unsigned int *)lpvData) : 0;
}
#elif defined WIN32
{
LPVOID lpvData = TlsGetValue(dwTlsIndex);
return *((unsigned int *)lpvData);
}
#else
return STATUS(WI_ERROR_NO_MULTITHREAD_SUPPORT);
#endif
#else
return 0;
#endif
}
示例9: async_fibre_init_dispatcher
int async_fibre_init_dispatcher(async_fibre *fibre)
{
LPVOID dispatcher;
dispatcher = (LPVOID)TlsGetValue(asyncwindispatch);
if (dispatcher == NULL) {
fibre->fibre = ConvertThreadToFiber(NULL);
if (fibre->fibre == NULL) {
fibre->converted = 0;
fibre->fibre = GetCurrentFiber();
if (fibre->fibre == NULL)
return 0;
} else {
fibre->converted = 1;
}
if (TlsSetValue(asyncwindispatch, (LPVOID)fibre->fibre) == 0)
return 0;
} else {
fibre->fibre = dispatcher;
}
return 1;
}
示例10: dc_get_device_status
int dc_get_device_status(wchar_t *device, dc_status *status)
{
dc_ioctl dctl;
u32 bytes;
int succs;
wcscpy(dctl.device, device);
succs = DeviceIoControl(
TlsGetValue(h_tls_idx), DC_CTL_STATUS,
&dctl, sizeof(dc_ioctl), status, sizeof(dc_status), &bytes, NULL);
if (succs == 0) {
return ST_ERROR;
} else
{
if (status->mnt_point[0] == 0) {
wcscpy(status->mnt_point, device); /* -- */
}
return dctl.status;
}
}
示例11: dc_get_boot_device
int dc_get_boot_device(wchar_t *device)
{
dc_ioctl dctl;
u32 bytes;
int succs;
wcscpy(dctl.device, L"\\ArcName\\multi(0)disk(0)rdisk(0)partition(1)");
succs = DeviceIoControl(
TlsGetValue(h_tls_idx), DC_CTL_RESOLVE,
&dctl, sizeof(dctl), &dctl, sizeof(dctl), &bytes, NULL);
if (succs != 0)
{
if (dctl.status == ST_OK) {
wcscpy(device, dctl.device);
}
return dctl.status;
} else {
return ST_ERROR;
}
}
示例12: pthread_cleanup_pop
/**
* Pop and call the top cleanup routine.
* The pthread_cleanup_pop() function pops the top cleanup routine off
* of the current threads cleanup routine stack, and, if execute is
* non-zero, it will execute the function. If there is no cleanup
* routine then pthread_cleanup_pop() does nothing.
*
* @param execute If execute is non-zero, the top-most clean-up handler
* is popped and executed.
* @bug The main thread do not support cleanup routines.
*/
void pthread_cleanup_pop(int execute)
{
arch_thread_info *pv = TlsGetValue(libpthread_tls_index);
if (pv != NULL) {
arch_thread_cleanup_list *node = pv->cleanup_list, *prev;
if (node == NULL) return;
while(node->next != NULL)
node = node->next;
if (execute) {
node->cleaner(node->arg);
}
prev = node->prev;
free(node);
if(prev == NULL)
pv->cleanup_list = NULL;
else
prev->next = NULL;
}
}
示例13: _gpg_err_deinit
/* Deinitialize libgpg-error. This function is only used in special
circumstances. No gpg-error function should be used after this
function has been called. A value of 0 passed for MODE
deinitializes the entire libgpg-error, a value of 1 releases
resources allocated for the current thread and only that thread may
not anymore access libgpg-error after such a call. Under Windows
this function may be called from the DllMain function of a DLL
which statically links to libgpg-error. */
void
_gpg_err_deinit (int mode)
{
#if defined (HAVE_W32_SYSTEM) && !defined(DLL_EXPORT)
struct tls_space_s *tls;
tls = TlsGetValue (tls_index);
if (tls)
{
TlsSetValue (tls_index, NULL);
LocalFree (tls);
}
if (mode == 0)
{
TlsFree (tls_index);
tls_index = TLS_OUT_OF_INDEXES;
}
#else
(void)mode;
#endif
}
示例14: Assert
/* static */
bool JsrtContext::TrySetCurrent(JsrtContext * context)
{
Assert(s_tlsSlot != TLS_OUT_OF_INDEXES);
ThreadContext * threadContext;
//We are not pinning the context after SetCurrentContext, so if the context is not pinned
//it might be reclaimed half way during execution. In jsrtshell the runtime was optimized out
//at time of JsrtContext::Run by the compiler.
//The change is to pin the context at setconcurrentcontext, and unpin the previous one. In
//JsDisposeRuntime we'll reject if current context is active, so that will make sure all
//contexts are unpinned at time of JsDisposeRuntime.
if (context != nullptr)
{
threadContext = context->GetScriptContext()->GetThreadContext();
if (!ThreadContextTLSEntry::TrySetThreadContext(threadContext))
{
return false;
}
threadContext->GetRecycler()->RootAddRef((LPVOID)context);
}
else
{
if (!ThreadContextTLSEntry::ClearThreadContext(true))
{
return false;
}
}
JsrtContext* originalContext = (JsrtContext*) TlsGetValue(s_tlsSlot);
if (originalContext != nullptr)
{
originalContext->GetScriptContext()->GetRecycler()->RootRelease((LPVOID) originalContext);
}
TlsSetValue(s_tlsSlot, context);
return true;
}
示例15: set_error
static void set_error(const char * e)
{
char * s;
char * old_s;
size_t len;
DWORD slot = get_tl_error_slot();
if (slot == TLS_OUT_OF_INDEXES)
return;
len = strlen(e) * sizeof(char) + sizeof(char);
s = LocalAlloc(LMEM_FIXED, len);
if (s == NULL)
return;
old_s = (char *) TlsGetValue(slot);
TlsSetValue(slot, (LPVOID) s);
if (old_s != NULL)
LocalFree(old_s);
}