本文整理汇总了C++中MUTEX_INIT函数的典型用法代码示例。如果您正苦于以下问题:C++ MUTEX_INIT函数的具体用法?C++ MUTEX_INIT怎么用?C++ MUTEX_INIT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了MUTEX_INIT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例6: _tdispInit
void _tdispInit(void) {
MUTEX_INIT();
MUTEX_ENTER();
tdisp_lld_init();
MUTEX_LEAVE();
}
示例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
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例13: MUTEX_INIT
Logging::Logging(bool debug) {
mDebug = debug;
MUTEX_INIT();
strcpy(mErrBuf, "Unknown Error");
strcpy(mLogBuf, "Unknown Message");
}
示例14: TEST
TEST(Mutex, test) {
MUTEX mx;
MUTEX_INIT(mx);
MUTEX_LOCK(mx);
MUTEX_UNLOCK(mx);
MUTEX_DESTROY(mx);
}
示例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;
}