这篇教程C++ tsrm_mutex_lock函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中tsrm_mutex_lock函数的典型用法代码示例。如果您正苦于以下问题:C++ tsrm_mutex_lock函数的具体用法?C++ tsrm_mutex_lock怎么用?C++ tsrm_mutex_lock使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了tsrm_mutex_lock函数的24个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: begin_read/* ts management functions */static void begin_read(TsHashTable *ht){#ifdef ZTS tsrm_mutex_lock(ht->mx_reader); if ((++(ht->reader)) == 1) { tsrm_mutex_lock(ht->mx_writer); } tsrm_mutex_unlock(ht->mx_reader);#endif}
开发者ID:2yeslater,项目名称:php_threading,代码行数:11,
示例2: tsrm_tls_get/* fetches the requested resource for the current thread */TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id){/*{{{*/ THREAD_T thread_id; int hash_value; tsrm_tls_entry *thread_resources; if (!th_id) { /* Fast path for looking up the resources for the current * thread. Its used by just about every call to * ts_resource_ex(). This avoids the need for a mutex lock * and our hashtable lookup. */ thread_resources = tsrm_tls_get(); if (thread_resources) { TSRM_ERROR((TSRM_ERROR_LEVEL_INFO, "Fetching resource id %d for current thread %d", id, (long) thread_resources->thread_id)); /* Read a specific resource from the thread's resources. * This is called outside of a mutex, so have to be aware about external * changes to the structure as we read it. */ TSRM_SAFE_RETURN_RSRC(thread_resources->storage, id, thread_resources->count); } thread_id = tsrm_thread_id(); } else { thread_id = *th_id; } TSRM_ERROR((TSRM_ERROR_LEVEL_INFO, "Fetching resource id %d for thread %ld", id, (long) thread_id)); tsrm_mutex_lock(tsmm_mutex); hash_value = THREAD_HASH_OF(thread_id, tsrm_tls_table_size); thread_resources = tsrm_tls_table[hash_value]; if (!thread_resources) { allocate_new_resource(&tsrm_tls_table[hash_value], thread_id); return ts_resource_ex(id, &thread_id); } else { do { if (thread_resources->thread_id == thread_id) { break; } if (thread_resources->next) { thread_resources = thread_resources->next; } else { allocate_new_resource(&thread_resources->next, thread_id); return ts_resource_ex(id, &thread_id); /* * thread_resources = thread_resources->next; * break; */ } } while (thread_resources); } tsrm_mutex_unlock(tsmm_mutex); /* Read a specific resource from the thread's resources. * This is called outside of a mutex, so have to be aware about external * changes to the structure as we read it. */ TSRM_SAFE_RETURN_RSRC(thread_resources->storage, id, thread_resources->count);}/*}}}*/
开发者ID:daniel-higa,项目名称:php-src,代码行数:61,
示例3: _crypt_extended_init_rvoid _crypt_extended_init_r(void){#ifdef PHP_WIN32 LONG volatile initialized = 0;#elif defined(HAVE_ATOMIC_H) /* Solaris 10 defines atomic API within */ volatile unsigned int initialized = 0;#else static volatile sig_atomic_t initialized = 0;#endif#ifdef ZTS tsrm_mutex_lock(php_crypt_extended_init_lock);#endif if (!initialized) {#ifdef PHP_WIN32 InterlockedIncrement(&initialized);#elif defined(HAVE_SYNC_FETCH_AND_ADD) __sync_fetch_and_add(&initialized, 1);#elif (defined(__GNUC__) && (__GNUC__ >= 3)) initialized = 1;#elif defined(HAVE_ATOMIC_H) /* Solaris 10 defines atomic API within */ membar_producer(); atomic_add_int(&initialized, 1);#endif _crypt_extended_init(); }#ifdef ZTS tsrm_mutex_unlock(php_crypt_extended_init_lock);#endif}
开发者ID:NieHao,项目名称:Tomato-RAF,代码行数:31,
示例4: zend_shared_alloc_lockvoid zend_shared_alloc_lock(void){#ifndef ZEND_WIN32#ifdef ZTS tsrm_mutex_lock(zts_lock);#endif#if 0 /* this will happen once per process, and will un-globalize mem_write_lock */ if (mem_write_lock.l_pid == -1) { mem_write_lock.l_pid = getpid(); }#endif while (1) { if (fcntl(lock_file, F_SETLKW, &mem_write_lock) == -1) { if (errno == EINTR) { continue; } zend_accel_error(ACCEL_LOG_ERROR, "Cannot create lock - %s (%d)", strerror(errno), errno); } break; }#else zend_shared_alloc_lock_win32();#endif ZCG(locked) = 1;}
开发者ID:13572293130,项目名称:php-src,代码行数:30,
示例5: xc_mutex_lock/* }}} */void xc_mutex_lock(xc_mutex_t *mutex) /* {{{ */{#ifdef XC_MUTEX_USE_PTHREAD if (pthread_mutex_lock(&mutex->pthread_mutex) < 0) { zend_error(E_ERROR, "xc_mutex failed errno:%d", errno); }#endif#ifdef XC_MUTEX_USE_TSRM if (tsrm_mutex_lock(mutex->tsrm_mutex) < 0) { zend_error(E_ERROR, "xc_mutex failed errno:%d", errno); }#endif#ifdef XC_MUTEX_USE_FCNTL if (xc_want_inter_process()) { xc_fcntl_mutex(&mutex->fcntl_mutex); }#endif#ifndef NDEBUG assert(!mutex->locked); mutex->locked = 1; assert(mutex->locked);#endif}
开发者ID:lighttpd,项目名称:xcache,代码行数:27,
示例6: ts_free_id/* deallocates all occurrences of a given id */void ts_free_id(ts_rsrc_id id){/*{{{*/ int i; int j = TSRM_UNSHUFFLE_RSRC_ID(id); tsrm_mutex_lock(tsmm_mutex); TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Freeing resource id %d", id)); if (tsrm_tls_table) { for (i=0; i<tsrm_tls_table_size; i++) { tsrm_tls_entry *p = tsrm_tls_table[i]; while (p) { if (p->count > j && p->storage[j]) { if (resource_types_table && resource_types_table[j].dtor) { resource_types_table[j].dtor(p->storage[j]); } free(p->storage[j]); p->storage[j] = NULL; } p = p->next; } } } resource_types_table[j].done = 1; tsrm_mutex_unlock(tsmm_mutex); TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Successfully freed resource id %d", id));}/*}}}*/
开发者ID:daniel-higa,项目名称:php-src,代码行数:32,
示例7: php_http_openssl_thread_lockstatic void php_http_openssl_thread_lock(int mode, int n, const char * file, int line){ if (mode & CRYPTO_LOCK) { tsrm_mutex_lock(php_http_openssl_tsl[n]); } else { tsrm_mutex_unlock(php_http_openssl_tsl[n]); }}
开发者ID:m6w6,项目名称:ext-http,代码行数:8,
示例8: php_win32_free_rng_lockvoid php_win32_free_rng_lock(){ tsrm_mutex_lock(php_lock_win32_cryptoctx); CryptReleaseContext(hCryptProv, 0); has_crypto_ctx = 0; tsrm_mutex_unlock(php_lock_win32_cryptoctx); tsrm_mutex_free(php_lock_win32_cryptoctx);}
开发者ID:Doap,项目名称:php-src,代码行数:9,
示例9: end_readstatic void end_read(TsHashTable *ht){#ifdef ZTS tsrm_mutex_lock(ht->mx_reader); if ((--(ht->reader)) == 0) { tsrm_mutex_unlock(ht->mx_writer); } tsrm_mutex_unlock(ht->mx_reader);#endif}
开发者ID:2yeslater,项目名称:php_threading,代码行数:10,
示例10: ts_allocate_id/* allocates a new thread-safe-resource id */TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, size_t size, ts_allocate_ctor ctor, ts_allocate_dtor dtor){/*{{{*/ int i; TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Obtaining a new resource id, %d bytes", size)); tsrm_mutex_lock(tsmm_mutex); /* obtain a resource id */ *rsrc_id = TSRM_SHUFFLE_RSRC_ID(id_count++); TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Obtained resource id %d", *rsrc_id)); /* store the new resource type in the resource sizes table */ if (resource_types_table_size < id_count) { tsrm_resource_type *_tmp; _tmp = (tsrm_resource_type *) realloc(resource_types_table, sizeof(tsrm_resource_type)*id_count); if (!_tmp) { tsrm_mutex_unlock(tsmm_mutex); TSRM_ERROR((TSRM_ERROR_LEVEL_ERROR, "Unable to allocate storage for resource")); *rsrc_id = 0; return 0; } resource_types_table = _tmp; resource_types_table_size = id_count; } resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].size = size; resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].ctor = ctor; resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].dtor = dtor; resource_types_table[TSRM_UNSHUFFLE_RSRC_ID(*rsrc_id)].done = 0; /* enlarge the arrays for the already active threads */ for (i=0; i<tsrm_tls_table_size; i++) { tsrm_tls_entry *p = tsrm_tls_table[i]; while (p) { if (p->count < id_count) { int j; p->storage = (void *) realloc(p->storage, sizeof(void *)*id_count); for (j=p->count; j<id_count; j++) { p->storage[j] = (void *) malloc(resource_types_table[j].size); if (resource_types_table[j].ctor) { resource_types_table[j].ctor(p->storage[j]); } } p->count = id_count; } p = p->next; } } tsrm_mutex_unlock(tsmm_mutex); TSRM_ERROR((TSRM_ERROR_LEVEL_CORE, "Successfully allocated new resource id %d", *rsrc_id)); return *rsrc_id;}/*}}}*/
开发者ID:daniel-higa,项目名称:php-src,代码行数:56,
示例11: mkd_shlib_destructorvoidmkd_shlib_destructor(){ /* on merge: added critical section */#ifdef ZTS tsrm_mutex_lock(tags_mutex);#endif mkd_deallocate_tags();#ifdef ZTS tsrm_mutex_unlock(tags_mutex);#endif}
开发者ID:cataphract,项目名称:php-discount,代码行数:12,
示例12: mkd_shlib_destructorvoidmkd_shlib_destructor(){ /* on merge: added critical section */#ifdef ZTS tsrm_mutex_lock(tags_mutex);#endif /* on merge: reduced to call to mkd_deallocate_tags(); */ /*if ( !need_to_setup ) { need_to_setup = 1;*/ mkd_deallocate_tags(); /*}*/#ifdef ZTS tsrm_mutex_unlock(tags_mutex);#endif}
开发者ID:stilldavid,项目名称:php-discount,代码行数:16,
示例13: tsrm_thread_id/* allocates a new interpreter context */void *tsrm_new_interpreter_context(void){/*{{{*/ tsrm_tls_entry *new_ctx, *current; THREAD_T thread_id; thread_id = tsrm_thread_id(); tsrm_mutex_lock(tsmm_mutex); current = tsrm_tls_get(); allocate_new_resource(&new_ctx, thread_id); /* switch back to the context that was in use prior to our creation * of the new one */ return tsrm_set_interpreter_context(current);}/*}}}*/
开发者ID:daniel-higa,项目名称:php-src,代码行数:17,
示例14: php_win32_get_random_bytesPHPAPI int php_win32_get_random_bytes(unsigned char *buf, size_t size) { /* {{{ */ unsigned int has_contextg = 0; BOOL ret; size_t i = 0;#ifdef ZTS tsrm_mutex_lock(php_lock_win32_cryptoctx);#endif if (has_crypto_ctx == 0) { /* CRYPT_VERIFYCONTEXT > only hashing&co-like use, no need to acces prv keys */ if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_MACHINE_KEYSET|CRYPT_VERIFYCONTEXT )) { /* Could mean that the key container does not exist, let try again by asking for a new one. If it fails here, it surely means that the user running this process does not have the permission(s) to use this container. */ if (GetLastError() == NTE_BAD_KEYSET) { if (CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET | CRYPT_MACHINE_KEYSET | CRYPT_VERIFYCONTEXT )) { has_crypto_ctx = 1; } else { has_crypto_ctx = 0; } } } else { has_crypto_ctx = 1; } }#ifdef ZTS tsrm_mutex_unlock(php_lock_win32_cryptoctx);#endif if (has_crypto_ctx == 0) { return FAILURE; } ret = CryptGenRandom(hCryptProv, size, buf); if (ret) { return SUCCESS; } else { return FAILURE; }}
开发者ID:Doap,项目名称:php-src,代码行数:46,
示例15: _crypt_extended_init_rvoid _crypt_extended_init_r(void){ static volatile sig_atomic_t initialized = 0;#ifdef ZTS tsrm_mutex_lock(php_crypt_extended_init_lock);#endif if (initialized) { return; } else { _crypt_extended_init(); initialized = 1; }#ifdef ZTS tsrm_mutex_unlock(php_crypt_extended_init_lock);#endif}
开发者ID:practicalweb,项目名称:php-src,代码行数:18,
示例16: ts_free_worker_threads/* frees all resources allocated for all threads except current */void ts_free_worker_threads(void){/*{{{*/ tsrm_tls_entry *thread_resources; int i; THREAD_T thread_id = tsrm_thread_id(); int hash_value; tsrm_tls_entry *last=NULL; tsrm_mutex_lock(tsmm_mutex); hash_value = THREAD_HASH_OF(thread_id, tsrm_tls_table_size); thread_resources = tsrm_tls_table[hash_value]; while (thread_resources) { if (thread_resources->thread_id != thread_id) { for (i=0; i<thread_resources->count; i++) { if (resource_types_table[i].dtor) { resource_types_table[i].dtor(thread_resources->storage[i]); } } for (i=0; i<thread_resources->count; i++) { free(thread_resources->storage[i]); } free(thread_resources->storage); if (last) { last->next = thread_resources->next; } else { tsrm_tls_table[hash_value] = thread_resources->next; } free(thread_resources); if (last) { thread_resources = last->next; } else { thread_resources = tsrm_tls_table[hash_value]; } } else { if (thread_resources->next) { last = thread_resources; } thread_resources = thread_resources->next; } } tsrm_mutex_unlock(tsmm_mutex);}/*}}}*/
开发者ID:daniel-higa,项目名称:php-src,代码行数:44,
示例17: mkd_initializevoidmkd_initialize(){ /* on merge: added critical section */#ifdef ZTS tsrm_mutex_lock(tags_mutex);#endif /* on merge: reduced to call to mkd_prepare_tags(); */ /* if ( need_to_initrng ) { need_to_initrng = 0; INITRNG(time(0)); } if ( need_to_setup ) { need_to_setup = 0;*/ mkd_prepare_tags(); /*}*/#ifdef ZTS tsrm_mutex_unlock(tags_mutex);#endif}
开发者ID:stilldavid,项目名称:php-discount,代码行数:21,
示例18: tsrm_mutex_lockancillary_reg_entry *get_ancillary_reg_entry(int cmsg_level, int msg_type){ anc_reg_key key = { cmsg_level, msg_type }; ancillary_reg_entry *entry;#ifdef ZTS tsrm_mutex_lock(ancillary_mutex);#endif if (!ancillary_registry.initialized) { init_ancillary_registry(); }#ifdef ZTS tsrm_mutex_unlock(ancillary_mutex);#endif if ((entry = zend_hash_str_find_ptr(&ancillary_registry.ht, (char*)&key, sizeof(key) - 1)) != NULL) { return entry; } else { return NULL; }}
开发者ID:20uf,项目名称:php-src,代码行数:21,
示例19: tsrm_mutex_lockancillary_reg_entry *get_ancillary_reg_entry(int cmsg_level, int msg_type){ anc_reg_key key = { cmsg_level, msg_type }; ancillary_reg_entry *entry;#ifdef ZTS tsrm_mutex_lock(ancillary_mutex);#endif if (!ancillary_registry.initialized) { init_ancillary_registry(); }#ifdef ZTS tsrm_mutex_unlock(ancillary_mutex);#endif if (zend_hash_find(&ancillary_registry.ht, (char*)&key, sizeof(key), (void**)&entry) == SUCCESS) { return entry; } else { return NULL; }}
开发者ID:AzerTyQsdF,项目名称:osx,代码行数:22,
示例20: zend_shared_alloc_lockvoid zend_shared_alloc_lock(TSRMLS_D){#ifndef ZEND_WIN32#ifdef ZTS tsrm_mutex_lock(zts_lock);#endif#if 0 /* this will happen once per process, and will un-globalize mem_write_lock */ if (mem_write_lock.l_pid == -1) { mem_write_lock.l_pid = getpid(); }#endif while (1) { if (fcntl(lock_file, F_SETLKW, &mem_write_lock) == -1) { if (errno == EINTR) { continue; } zend_accel_error(ACCEL_LOG_ERROR, "Cannot create lock - %s (%d)", strerror(errno), errno); } break; }#else zend_shared_alloc_lock_win32();#endif ZCG(locked) = 1; /* Prepare translation table * * Make it persistent so that it uses malloc() and allocated blocks * won't be taken from space which is freed by efree in memdup. * Otherwise it leads to false matches in memdup check. */ zend_hash_init(&xlat_table, 100, NULL, NULL, 1);}
开发者ID:sunnystone85,项目名称:php-src,代码行数:38,
示例21: begin_writestatic void begin_write(TsHashTable *ht){#ifdef ZTS tsrm_mutex_lock(ht->mx_writer);#endif}
开发者ID:2yeslater,项目名称:php_threading,代码行数:6,
示例22: call_backtracevoid call_backtrace(int fd, zend_backtrace_globals* g, backtrace_callback_t callback){#ifdef DEBUG fprintf(stderr, "[%d]: call_backtrace()/n", getpid()); fflush(stderr);#endif if (!callback) { return; } HashPosition pos; void** current; THREAD_T self = tsrm_thread_id(); int processed_self = 0; tsrm_mutex_lock(mutex); for ( zend_hash_internal_pointer_reset_ex(&thread_ids, &pos); SUCCESS == zend_hash_get_current_data_ex(&thread_ids, (void**)¤t, &pos); zend_hash_move_forward_ex(&thread_ids, &pos) ) { char* key; uint key_len; ulong idx; int type; type = zend_hash_get_current_key_ex(&thread_ids, &key, &key_len, &idx, 0, &pos); if (HASH_KEY_IS_STRING == type) { idx = atol(key); }#ifdef DEBUG fprintf(stderr, "[%d]: Trying thread %lu/n", getpid(), idx); fflush(stderr);#endif if (idx) {#if defined(PTHREADS) int res = pthread_kill((pthread_t)idx, 0); if (res) { continue; }#elif defined(GNUPTH) int res = pth_raise((pth_t)idx, 0); if (!res) { continue; }#endif#ifdef DEBUG fprintf(stderr, "[%d]: Processing thread %lu/n", getpid(), idx); fflush(stderr);#endif THREAD_T thread_id = idx;#if defined(PTHREADS) if (!processed_self && pthread_equal(thread_id, self)) { processed_self = 1; }#else if (thread_id == self) { processed_self = 1; }#endif void*** tsrm_ls = (void***)ts_resource_ex(0, &thread_id); callback(fd, g, tsrm_ls);#ifdef DEBUG fprintf(stderr, "[%d]: Processed thread %lu/n", getpid(), idx); fflush(stderr);#endif } } if (!processed_self) {#ifdef DEBUG fprintf(stderr, "[%d]: Processing self/n", getpid()); fflush(stderr);#endif void*** tsrm_ls = (void***)ts_resource_ex(0, (THREAD_T*)0); callback(fd, g, tsrm_ls);#ifdef DEBUG fprintf(stderr, "[%d]: Processed self/n", getpid()); fflush(stderr);#endif } tsrm_mutex_unlock(mutex);}
开发者ID:bullsoft,项目名称:php-backtrace,代码行数:93,
示例23: tsrm_tls_get/* fetches the requested resource for the current thread */TSRM_API void *ts_resource_ex(ts_rsrc_id id, THREAD_T *th_id){ THREAD_T thread_id; int hash_value; tsrm_tls_entry *thread_resources;#ifdef NETWARE /* The below if loop is added for NetWare to fix an abend while unloading PHP * when an Apache unload command is issued on the system console. * While exiting from PHP, at the end for some reason, this function is called * with tsrm_tls_table = NULL. When this happened, the server abends when * tsrm_tls_table is accessed since it is NULL. */ if(tsrm_tls_table) {#endif if (!th_id) { /* Fast path for looking up the resources for the current * thread. Its used by just about every call to * ts_resource_ex(). This avoids the need for a mutex lock * and our hashtable lookup. */ thread_resources = tsrm_tls_get(); if (thread_resources) { TSRM_ERROR((TSRM_ERROR_LEVEL_INFO, "Fetching resource id %d for current thread %d", id, (long) thread_resources->thread_id)); /* Read a specific resource from the thread's resources. * This is called outside of a mutex, so have to be aware about external * changes to the structure as we read it. */ TSRM_SAFE_RETURN_RSRC(thread_resources->storage, id, thread_resources->count); } thread_id = tsrm_thread_id(); } else { thread_id = *th_id; } TSRM_ERROR((TSRM_ERROR_LEVEL_INFO, "Fetching resource id %d for thread %ld", id, (long) thread_id)); tsrm_mutex_lock(tsmm_mutex); hash_value = THREAD_HASH_OF(thread_id, tsrm_tls_table_size); thread_resources = tsrm_tls_table[hash_value]; if (!thread_resources) { allocate_new_resource(&tsrm_tls_table[hash_value], thread_id); return ts_resource_ex(id, &thread_id); } else { do { if (thread_resources->thread_id == thread_id) { break; } if (thread_resources->next) { thread_resources = thread_resources->next; } else { allocate_new_resource(&thread_resources->next, thread_id); return ts_resource_ex(id, &thread_id); /* * thread_resources = thread_resources->next; * break; */ } } while (thread_resources); } tsrm_mutex_unlock(tsmm_mutex); /* Read a specific resource from the thread's resources. * This is called outside of a mutex, so have to be aware about external * changes to the structure as we read it. */ TSRM_SAFE_RETURN_RSRC(thread_resources->storage, id, thread_resources->count);#ifdef NETWARE } /* if(tsrm_tls_table) */#endif}
开发者ID:kennyb,项目名称:php-broken,代码行数:73,
示例24: php_http_gnutls_mutex_lockstatic int php_http_gnutls_mutex_lock(void **m){ return tsrm_mutex_lock(*((MUTEX_T *) m));}
开发者ID:m6w6,项目名称:ext-http,代码行数:4,
注:本文中的tsrm_mutex_lock函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ tsrm_mutex_unlock函数代码示例 C++ tsp_verb函数代码示例 |