本文整理汇总了C++中MUTEX_INIT函数的典型用法代码示例。如果您正苦于以下问题:C++ MUTEX_INIT函数的具体用法?C++ MUTEX_INIT怎么用?C++ MUTEX_INIT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MUTEX_INIT函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: MUTEX_INIT
bool
OMR::Monitor::init(char *name)
{
_name = name;
MUTEX_INIT(_monitor);
bool rc = MUTEX_INIT(_monitor);
TR_ASSERT(rc == true, "error initializing monitor\n");
return true;
}
开发者ID:TianyuZuo,项目名称:omr,代码行数:9,代码来源:OMRMonitor.cpp
示例2: Logger
LoadBalancer::LoadBalancer(){
logger = new Logger(log_path); //日志类初始化
ClientRecvCorrectCount=ClientRecvIncorrectCount=ClientSendCount = 0;
ServerRecvCorrectCount=ServerRecvIncorrectCount=ServerSendCount = 0;
initilize(conf_path);
initilize_socket();
MUTEX_INIT(mutex_sendto);
MUTEX_INIT(mutex_print);
}
开发者ID:jk983294,项目名称:Store,代码行数:10,代码来源:LoadBalancer.cpp
示例3: initilize
Client::Client(unsigned id,unsigned usr_id, unsigned n){
this->id = id; this->usr_id = usr_id; this->n = n;
RecvCorrectCount=RecvIncorrectCount=SendCount = 0;
initilize(conf_path);
if (! SocketUtil::create_udp_socket(mysocket))
print_debugInformation("创建client socket错误");
isdebug = true;
MUTEX_INIT(mutex_sendto);
MUTEX_INIT(mutex_print);
}
开发者ID:jk983294,项目名称:Store,代码行数:10,代码来源:client.cpp
示例4: freerdp_chanman_init
/* this is called shortly after the application starts and
before any other function in the file
called only from main thread */
int
freerdp_chanman_init(void)
{
g_init_chan_man = NULL;
g_chan_man_list = NULL;
g_open_handle_sequence = 1;
MUTEX_INIT(g_mutex_init);
MUTEX_INIT(g_mutex_list);
return 0;
}
开发者ID:g-reno,项目名称:FreeRDP-old,代码行数:14,代码来源:libchanman.c
示例5: _hwnd
VDAgent::VDAgent()
: _hwnd (NULL)
, _hwnd_next_viewer (NULL)
, _user_lib (NULL)
, _add_clipboard_listener (NULL)
, _remove_clipboard_listener (NULL)
, _clipboard_owner (owner_none)
, _clipboard_tick (0)
, _buttons_state (0)
, _mouse_x (0)
, _mouse_y (0)
, _input_time (0)
, _control_event (NULL)
, _stop_event (NULL)
, _in_msg (NULL)
, _in_msg_pos (0)
, _pending_input (false)
, _running (false)
, _desktop_switch (false)
, _desktop_layout (NULL)
, _display_setting (VD_AGENT_REGISTRY_KEY)
, _vio_serial (NULL)
, _read_pos (0)
, _write_pos (0)
, _logon_desktop (false)
, _display_setting_initialized (false)
, _max_clipboard (-1)
, _client_caps (NULL)
, _client_caps_size (0)
, _log (NULL)
{
TCHAR log_path[MAX_PATH];
TCHAR temp_path[MAX_PATH];
_system_version = supported_system_version();
if (GetTempPath(MAX_PATH, temp_path)) {
swprintf_s(log_path, MAX_PATH, VD_AGENT_LOG_PATH, temp_path);
_log = VDLog::get(log_path);
}
ZeroMemory(&_input, sizeof(_input));
ZeroMemory(&_read_overlapped, sizeof(_read_overlapped));
ZeroMemory(&_write_overlapped, sizeof(_write_overlapped));
ZeroMemory(_read_buf, sizeof(_read_buf));
MUTEX_INIT(_control_mutex);
MUTEX_INIT(_message_mutex);
_singleton = this;
}
开发者ID:freedesktop-unofficial-mirror,项目名称:spice__win32__vd_agent,代码行数:48,代码来源:vdagent.cpp
示例6: _tdispInit
void _tdispInit(void) {
MUTEX_INIT();
MUTEX_ENTER();
tdisp_lld_init();
MUTEX_LEAVE();
}
开发者ID:sam0737,项目名称:ugfx-rads,代码行数:7,代码来源:tdisp.c
示例7: init_keepers
/*
* Initialize keeper states
*
* If there is a problem, return an error message (NULL for okay).
*
* Note: Any problems would be design flaws; the created Lua state is left
* unclosed, because it does not really matter. In production code, this
* function never fails.
*/
char const* init_keepers( int const _nbKeepers, lua_CFunction _on_state_create)
{
int i;
assert( _nbKeepers >= 1);
GNbKeepers = _nbKeepers;
GKeepers = malloc( _nbKeepers * sizeof( struct s_Keeper));
for( i = 0; i < _nbKeepers; ++ i)
{
// We need to load all base libraries in the keeper states so that the transfer databases are populated properly
//
// 'io' for debugging messages, 'package' because we need to require modules exporting idfuncs
// the others because they export functions that we may store in a keeper for transfer between lanes
lua_State* K = luaG_newstate( "*", _on_state_create);
if (!K)
return "out of memory";
STACK_CHECK( K)
// to see VM name in Decoda debugger
lua_pushliteral( K, "Keeper #");
lua_pushinteger( K, i + 1);
lua_concat( K, 2);
lua_setglobal( K, "decoda_name");
#if KEEPER_MODEL == KEEPER_MODEL_C
// create the fifos table in the keeper state
lua_pushlightuserdata( K, fifos_key);
lua_newtable( K);
lua_rawset( K, LUA_REGISTRYINDEX);
#endif // KEEPER_MODEL == KEEPER_MODEL_C
#if KEEPER_MODEL == KEEPER_MODEL_LUA
// use package.loaders[2] to find keeper microcode
lua_getglobal( K, "package"); // package
lua_getfield( K, -1, "loaders"); // package package.loaders
lua_rawgeti( K, -1, 2); // package package.loaders package.loaders[2]
lua_pushliteral( K, "lanes-keeper"); // package package.loaders package.loaders[2] "lanes-keeper"
STACK_MID( K, 4);
// first pcall loads lanes-keeper.lua, second one runs the chunk
if( lua_pcall( K, 1 /*args*/, 1 /*results*/, 0 /*errfunc*/) || lua_pcall( K, 0 /*args*/, 0 /*results*/, 0 /*errfunc*/))
{
// LUA_ERRRUN / LUA_ERRMEM / LUA_ERRERR
//
char const* err = lua_tostring( K, -1);
assert( err);
return err;
} // package package.loaders
STACK_MID( K, 2);
lua_pop( K, 2);
#endif // KEEPER_MODEL == KEEPER_MODEL_LUA
STACK_END( K, 0)
MUTEX_INIT( &GKeepers[i].lock_);
GKeepers[i].L = K;
//GKeepers[i].count = 0;
}
#if HAVE_KEEPER_ATEXIT_DESINIT
atexit( atexit_close_keepers);
#endif // HAVE_KEEPER_ATEXIT_DESINIT
return NULL; // ok
}
开发者ID:Abyss116,项目名称:luaplus51-all,代码行数:69,代码来源:keeper.c
示例8: MUTEX_INIT
/* initialize */
MMKEY *mmkey_init(char *file)
{
MMKEY *mmkey = NULL;
struct stat st = {0};
int fd = 0;
if(file && (fd = open(file, O_CREAT|O_RDWR, 0644)) > 0)
{
if((mmkey = (MMKEY *)calloc(1, sizeof(MMKEY))))
{
MUTEX_INIT(mmkey->mutex);
mmkey->fd = fd;
fstat(fd, &st);
mmkey->file_size = st.st_size;
MMKEY_MAP_INIT(mmkey);
mmkey->add = mmkey_add;
mmkey->xadd = mmkey_xadd;
mmkey->get = mmkey_get;
mmkey->del = mmkey_del;
mmkey->find = mmkey_find;
mmkey->maxfind = mmkey_maxfind;
mmkey->radd = mmkey_radd;
mmkey->rxadd = mmkey_rxadd;
mmkey->rget = mmkey_rget;
mmkey->rdel = mmkey_rdel;
mmkey->rfind = mmkey_rfind;
mmkey->rmaxfind = mmkey_rmaxfind;
mmkey->clean = mmkey_clean;
}
else
close(fd);
}
return mmkey;
}
开发者ID:cnangel,项目名称:hidbase,代码行数:35,代码来源:mmkey.c
示例9: perf_datafile_open
perf_datafile_t *
perf_datafile_open(isc_mem_t *mctx, const char *filename)
{
perf_datafile_t *dfile;
struct stat buf;
dfile = isc_mem_get(mctx, sizeof(*dfile));
if (dfile == NULL)
perf_log_fatal("out of memory");
dfile->mctx = mctx;
MUTEX_INIT(&dfile->lock);
dfile->pipe_fd = -1;
dfile->is_file = ISC_FALSE;
dfile->size = 0;
dfile->cached = ISC_FALSE;
dfile->maxruns = 1;
dfile->nruns = 0;
dfile->read_any = ISC_FALSE;
isc_buffer_init(&dfile->data, dfile->databuf, BUFFER_SIZE);
if (filename == NULL) {
dfile->fd = STDIN_FILENO;
} else {
dfile->fd = open(filename, O_RDONLY);
if (dfile->fd < 0)
perf_log_fatal("unable to open file: %s", filename);
if (fstat(dfile->fd, &buf) == 0 && S_ISREG(buf.st_mode)) {
dfile->is_file = ISC_TRUE;
dfile->size = buf.st_size;
}
}
nul_terminate(dfile);
return dfile;
}
开发者ID:NZRS,项目名称:bind9-collab,代码行数:35,代码来源:datafile.c
示例10: afs_tp_create
/**
* create a thread pool.
*
* @param[inout] pool_out address in which to store pool object pointer.
* @param[in] queue work queue serviced by thread pool
*
* @return operation status
* @retval 0 success
* @retval ENOMEM out of memory
*/
int
afs_tp_create(struct afs_thread_pool ** pool_out,
struct afs_work_queue * queue)
{
int ret = 0;
struct afs_thread_pool * pool;
ret = _afs_tp_alloc(pool_out);
if (ret) {
goto error;
}
pool = *pool_out;
MUTEX_INIT(&pool->lock, "pool", MUTEX_DEFAULT, 0);
CV_INIT(&pool->shutdown_cv, "pool shutdown", CV_DEFAULT, 0);
queue_Init(&pool->thread_list);
pool->work_queue = queue;
pool->entry = &_afs_tp_worker_default;
pool->rock = NULL;
pool->nthreads = 0;
pool->max_threads = 4;
pool->state = AFS_TP_STATE_INIT;
error:
return ret;
}
开发者ID:sanchit-matta,项目名称:openafs,代码行数:36,代码来源:thread_pool.c
示例11: RWLOCK_INIT
bool Trace::ConnectToFileAndStart(char *filename, unsigned int trace_index, int register_size, int register_count, bool is_big_endian) {
trace_index_ = trace_index;
is_big_endian_ = is_big_endian;
register_size_ = register_size;
register_count_ = register_count;
RWLOCK_INIT(db_lock_);
MUTEX_INIT(backing_mutex_);
registers_.resize(register_count_);
#ifdef _WIN32
fd_ = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
#else
fd_ = open(filename, O_RDONLY);
if (fd_ == -1) {
printf("ERROR: file open failed\n");
return false;
}
#endif
if (!remap_backing(sizeof(struct change))) {
printf("ERROR: remap backing failed\n");
return false;
}
THREAD_CREATE(thread, thread_entry, this);
return true;
}
开发者ID:BinaryAnalysisPlatform,项目名称:qira,代码行数:28,代码来源:Trace.cpp
示例12: fr_loginit
/* ------------------------------------------------------------------------ */
int fr_loginit()
{
int i;
for (i = IPL_LOGMAX; i >= 0; i--) {
iplt[i] = NULL;
ipll[i] = NULL;
iplh[i] = &iplt[i];
iplused[i] = 0;
bzero((char *)&iplcrc[i], sizeof(iplcrc[i]));
# ifdef IPL_SELECT
iplog_ss[i].read_waiter = 0;
iplog_ss[i].state = 0;
# endif
# if defined(linux) && defined(_KERNEL)
init_waitqueue_head(iplh_linux + i);
# endif
}
# if SOLARIS && defined(_KERNEL)
cv_init(&iplwait, "ipl condvar", CV_DRIVER, NULL);
# endif
MUTEX_INIT(&ipl_mutex, "ipf log mutex");
ipl_log_init = 1;
return 0;
}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:29,代码来源:ip_log.c
示例13: MUTEX_INIT
Logging::Logging(bool debug) {
mDebug = debug;
MUTEX_INIT();
strcpy(mErrBuf, "Unknown Error");
strcpy(mLogBuf, "Unknown Message");
}
开发者ID:CobraJet93,项目名称:kernel-3.10.54,代码行数:7,代码来源:Logging.cpp
示例14: TEST
TEST(Mutex, test) {
MUTEX mx;
MUTEX_INIT(mx);
MUTEX_LOCK(mx);
MUTEX_UNLOCK(mx);
MUTEX_DESTROY(mx);
}
开发者ID:leonindy,项目名称:cat,代码行数:7,代码来源:test_concurrent.cpp
示例15: atomic_new
atomic atomic_new(long int x) {
atomic a;
a=malloc(sizeof(struct atomicInt));
a->i=x;
MUTEX_INIT(&a->lock);
return a;
}
开发者ID:salmito,项目名称:leda,代码行数:7,代码来源:atomic.c
示例16: LOGGER_INIT
/* Initialize tasktable */
TASKTABLE *tasktable_init(char *taskfile, char *statusfile, char *logfile)
{
TASKTABLE *tasktable = NULL;
if(taskfile && (tasktable = (TASKTABLE *)calloc(1, sizeof(TASKTABLE))))
{
tasktable->add = tasktable_add;
tasktable->discard = tasktable_discard;
tasktable->ready = tasktable_ready;
tasktable->check_status = tasktable_check_status;
tasktable->check_timeout = tasktable_check_timeout;
tasktable->statusout = tasktable_statusout;
tasktable->md5sum = tasktable_md5sum;
tasktable->dump_task = tasktable_dump_task;
tasktable->resume_task = tasktable_resume_task;
tasktable->dump_status = tasktable_dump_status;
tasktable->resume_status = tasktable_resume_status;
tasktable->pop_block = tasktable_pop_block;
tasktable->update_status = tasktable_update_status;
tasktable->free_status = tasktable_free_status;
tasktable->clean = tasktable_clean;
tasktable->running_task_id = -1;
tasktable->running_task.id = -1;
LOGGER_INIT(tasktable->logger, logfile);
strcpy(tasktable->taskfile, taskfile);
tasktable->resume_task(tasktable);
strcpy(tasktable->statusfile, statusfile);
tasktable->resume_status(tasktable);
MUTEX_INIT(tasktable->mutex);
}
return tasktable;
}
开发者ID:houweifeng,项目名称:sbase,代码行数:33,代码来源:task.c
示例17: tcsd_threads_init
TSS_RESULT
tcsd_threads_init(void)
{
/* allocate the thread mgmt structure */
tm = calloc(1, sizeof(struct tcsd_thread_mgr));
if (tm == NULL) {
LogError("malloc of %zd bytes failed.", sizeof(struct tcsd_thread_mgr));
return TCSERR(TSS_E_OUTOFMEMORY);
}
/* initialize mutex */
MUTEX_INIT(tm->lock);
/* set the max threads variable from config */
tm->max_threads = tcsd_options.num_threads;
/* allocate each thread's data structure */
tm->thread_data = calloc(tcsd_options.num_threads, sizeof(struct tcsd_thread_data));
if (tm->thread_data == NULL) {
LogError("malloc of %zu bytes failed.",
tcsd_options.num_threads * sizeof(struct tcsd_thread_data));
free(tm);
return TCSERR(TSS_E_OUTOFMEMORY);
}
return TSS_SUCCESS;
}
开发者ID:secureTV,项目名称:android_tcsd,代码行数:26,代码来源:tcsd_threads.c
示例18: OMRPORT_ACCESS_FROM_OMRPORT
/**
* Initialize a new lock object.
* A lock must be initialized before it may be used.
*
* @param env
* @param options
* @param name Lock name
* @return TRUE on success
* @note Creates a store barrier.
*/
bool
MM_LightweightNonReentrantLock::initialize(MM_EnvironmentBase *env, ModronLnrlOptions *options, const char * name)
{
OMRPORT_ACCESS_FROM_OMRPORT(env->getPortLibrary());
/* initialize variables in case constructor was not called */
_initialized = false;
_tracing = NULL;
_extensions = env->getExtensions();
if (NULL != _extensions) {
J9Pool* tracingPool = _extensions->_lightweightNonReentrantLockPool;
if (NULL != tracingPool) {
omrthread_monitor_enter(_extensions->_lightweightNonReentrantLockPoolMutex);
_tracing = (J9ThreadMonitorTracing *)pool_newElement(tracingPool);
omrthread_monitor_exit(_extensions->_lightweightNonReentrantLockPoolMutex);
if (NULL == _tracing) {
goto error_no_memory;
}
_tracing->monitor_name = NULL;
if (NULL != name) {
uintptr_t length = omrstr_printf(NULL, 0, "[%p] %s", this, name) + 1;
if (length > MAX_LWNR_LOCK_NAME_SIZE) {
goto error_no_memory;
}
_tracing->monitor_name = _nameBuf;
if (NULL == _tracing->monitor_name) {
goto error_no_memory;
}
omrstr_printf(_tracing->monitor_name, length, "[%p] %s", this, name);
}
}
}
#if defined(OMR_ENV_DATA64)
if(0 != (((uintptr_t)this) % sizeof(uintptr_t))) {
omrtty_printf("GC FATAL: LWNRL misaligned.\n");
abort();
}
#endif
#if defined(J9MODRON_USE_CUSTOM_SPINLOCKS)
_initialized = omrgc_spinlock_init(&_spinlock) ? false : true;
_spinlock.spinCount1 = options->spinCount1;
_spinlock.spinCount2 = options->spinCount2;
_spinlock.spinCount3 = options->spinCount3;
#else /* J9MODRON_USE_CUSTOM_SPINLOCKS */
_initialized = MUTEX_INIT(_mutex) ? true : false;
#endif /* J9MODRON_USE_CUSTOM_SPINLOCKS */
return _initialized;
error_no_memory:
return false;
}
开发者ID:LinHu2016,项目名称:omr,代码行数:69,代码来源:LightweightNonReentrantLock.cpp
示例19: __tspi_add_table_entry
TSS_RESULT
__tspi_add_table_entry(TSS_HCONTEXT tspContext, BYTE *host, int type, struct host_table_entry **ret)
{
struct host_table_entry *entry, *tmp;
int hostlen;
entry = calloc(1, sizeof(struct host_table_entry));
if (entry == NULL) {
LogError("malloc of %zd bytes failed.", sizeof(struct host_table_entry));
return TSPERR(TSS_E_OUTOFMEMORY);
}
entry->tspContext = tspContext;
hostlen = strlen((char *)host)+1;
entry->hostname = (BYTE *)calloc(1, hostlen);
if (entry->hostname == NULL) {
LogError("malloc of %u bytes failed.", hostlen);
free(entry);
return TSPERR(TSS_E_OUTOFMEMORY);
}
memcpy(entry->hostname, host, hostlen);
entry->type = type;
entry->comm.buf_size = TCSD_INIT_TXBUF_SIZE;
entry->comm.buf = calloc(1, entry->comm.buf_size);
if (entry->comm.buf == NULL) {
LogError("malloc of %u bytes failed.", entry->comm.buf_size);
free(entry);
return TSPERR(TSS_E_OUTOFMEMORY);
}
MUTEX_INIT(entry->lock);
MUTEX_LOCK(ht->lock);
for (tmp = ht->entries; tmp; tmp = tmp->next) {
if (tmp->tspContext == tspContext) {
LogError("Tspi_Context_Connect attempted on an already connected context!");
MUTEX_UNLOCK(ht->lock);
free(entry->hostname);
free(entry->comm.buf);
free(entry);
return TSPERR(TSS_E_CONNECTION_FAILED);
}
}
if( ht->entries == NULL ) {
ht->entries = entry;
} else {
for (tmp = ht->entries; tmp->next; tmp = tmp->next)
;
tmp->next = entry;
}
MUTEX_UNLOCK(ht->lock);
*ret = entry;
return TSS_SUCCESS;
}
开发者ID:IIJ-NetBSD,项目名称:netbsd-src,代码行数:59,代码来源:hosttable.c
示例20: InitStats
static void InitStats(UDPIO_STATS *stats)
{
MUTEX_INIT(&stats->mutex);
stats->total.bytes = stats->total.pkts = (UINT64) 0;
stats->len.min = stats->len.max = 0;
stats->tstamp = utilTimeStamp();
stats->error.count = stats->error.tstamp = 0;
}
开发者ID:jandog8990,项目名称:asl-station-processor,代码行数:8,代码来源:udpio.c
注:本文中的MUTEX_INIT函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论