当前位置: 首页>>代码示例>>C++>>正文


C++ THREAD_UNLOCK函数代码示例

本文整理汇总了C++中THREAD_UNLOCK函数的典型用法代码示例。如果您正苦于以下问题:C++ THREAD_UNLOCK函数的具体用法?C++ THREAD_UNLOCK怎么用?C++ THREAD_UNLOCK使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了THREAD_UNLOCK函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: event_disable_readwrite

static void event_disable_readwrite(ACL_EVENT *eventp, ACL_VSTREAM *stream)
{
	const char *myname = "event_disable_readwrite";
	EVENT_SELECT_THR *event_thr = (EVENT_SELECT_THR *) eventp;
	ACL_EVENT_FDTABLE *fdp;
	ACL_SOCKET sockfd;

	sockfd = ACL_VSTREAM_SOCK(stream);

	THREAD_LOCK(&event_thr->event.tb_mutex);
	if (!FD_ISSET(sockfd, &event_thr->xmask)) {
		acl_msg_error("%s(%d): sockfd(%d) not be set",
			myname, __LINE__, sockfd);
		THREAD_UNLOCK(&event_thr->event.tb_mutex);
		return;
	}
	fdp = (ACL_EVENT_FDTABLE *) stream->fdp;
	if (fdp == NULL) {
		acl_msg_error("%s(%d): fdp null", myname, __LINE__);
		THREAD_UNLOCK(&event_thr->event.tb_mutex);
		return;
	}

	if (fdp->fdidx == -1)
		acl_msg_fatal("%s(%d): fdidx(%d) invalid",
			myname, __LINE__, fdp->fdidx);

	FD_CLR(sockfd, &event_thr->xmask);
	FD_CLR(sockfd, &event_thr->rmask);
	FD_CLR(sockfd, &event_thr->wmask);

	fdp->flag = 0;

	if (eventp->maxfd == sockfd)
		eventp->maxfd = ACL_SOCKET_INVALID;
	if (eventp->fdtabs[fdp->fdidx] == fdp) {
		if (fdp->fdidx < --eventp->fdcnt) {
			eventp->fdtabs[fdp->fdidx] = eventp->fdtabs[eventp->fdcnt];
			eventp->fdtabs[fdp->fdidx]->fdidx = fdp->fdidx;
		}
	} else
		acl_msg_fatal("%s(%d): fdidx(%d)'s fdp invalid",
			myname, __LINE__, fdp->fdidx);

	if (fdp->fdidx_ready > 0
	    && fdp->fdidx_ready < eventp->fdcnt_ready
	    && eventp->fdtabs_ready[fdp->fdidx_ready] == fdp)
	{
		eventp->fdtabs_ready[fdp->fdidx_ready] = NULL;
	}
	event_fdtable_free(fdp);
	stream->fdp = NULL;
	stream->nrefer--;
	THREAD_UNLOCK(&event_thr->event.tb_mutex);
}
开发者ID:aaronshang,项目名称:acl,代码行数:55,代码来源:events_select_thr.c

示例2: armci_send_req_msg_strided

/*\ client sends strided data + request to server
\*/
int armci_send_req_msg_strided(int proc, request_header_t *msginfo,char *ptr,
                               int strides, int stride_arr[], int count[])
{
int cluster = armci_clus_id(proc);
int stat, bytes;

    if(DEBUG_){
      printf("%d:armci_send_req_msg_strided: op=%d to=%d bytes= %d \n",armci_me,
             msginfo->operation,proc,msginfo->datalen);
      fflush(stdout);
    }

    /* we write header + data descriptor */
    bytes = sizeof(request_header_t) + msginfo->dscrlen;

    THREAD_LOCK(armci_user_threads.net_lock);

    stat = armci_WriteToSocket(SRV_sock[cluster], msginfo, bytes);
    if(stat<0)armci_die("armci_send_strided:write failed",stat);
#if defined(USE_SOCKET_VECTOR_API)
    if(msginfo->operation==PUT && msginfo->datalen==0)
        armci_SendStridedToSocket( SRV_sock[cluster],ptr,stride_arr,count,
             strides,(struct iovec *)(msginfo+1) );
    else
#endif
    /* for larger blocks write directly to socket thus avoiding memcopy */
    armci_write_strided_sock(ptr, strides,stride_arr,count,SRV_sock[cluster]);

    THREAD_UNLOCK(armci_user_threads.net_lock);

    return 0;
}
开发者ID:dmlb2000,项目名称:nwchem-cml,代码行数:34,代码来源:dataserv.c

示例3: get_remote

void get_remote(double *buf, int I, int J)
{
    int proc_owner;
    int edge, size;

#ifdef USE_MUTEX
    THREAD_LOCK(mutex);
#endif

    proc_owner = block_owner(I, J) / th_per_p;

    edge = n%block_size;
    if (edge == 0) {
        edge = block_size;
    }

    if ((I == nblocks-1) && (J == nblocks-1)) {
        size = edge*edge;
    }
    else if ((I == nblocks-1) || (J == nblocks-1)) {
        size = edge*block_size;
    }
    else {
        size = block_size*block_size;
    }
    size = size * sizeof(double);

    if (proc_owner == me) memcpy(buf, a[I+J*nblocks], size);
    else ARMCI_Get(a[I+J*nblocks], buf, size, proc_owner);

#ifdef USE_MUTEX
    THREAD_UNLOCK(mutex);
#endif
}
开发者ID:bcernohous,项目名称:ga,代码行数:34,代码来源:lu-block-th.c

示例4: ga_chromosome_integer_deallocate

GAULFUNC void ga_chromosome_integer_deallocate( population *pop,
                                       entity *corpse )
  {

  if (!pop) die("Null pointer to population structure passed.");
  if (!corpse) die("Null pointer to entity structure passed.");

  if (corpse->chromosome==NULL)
    die("This entity already contains no chromosomes.");

#ifdef USE_CHROMO_CHUNKS
  THREAD_LOCK(pop->chromo_chunk_lock);
  mem_chunk_free(pop->chromo_chunk, corpse->chromosome[0]);
  mem_chunk_free(pop->chromoarray_chunk, corpse->chromosome);
  corpse->chromosome=NULL;

  if (mem_chunk_isempty(pop->chromo_chunk))
    {
    mem_chunk_destroy(pop->chromo_chunk);
    mem_chunk_destroy(pop->chromoarray_chunk);
    pop->chromo_chunk = NULL;
    }
  THREAD_UNLOCK(pop->chromo_chunk_lock);
#else
  s_free(corpse->chromosome[0]);
  s_free(corpse->chromosome);
  corpse->chromosome=NULL;
#endif

  return;
  }
开发者ID:versionzero,项目名称:gaul,代码行数:31,代码来源:ga_chromo.c

示例5: random_seed

GAULFUNC void random_seed(const unsigned int seed)
  { 
  int	i; 

#ifdef USE_OPENMP
  if (is_initialised == FALSE)
    {
    omp_init_lock(&random_state_lock);
    is_initialised = TRUE;
    }
#else
  is_initialised = TRUE;
#endif

  THREAD_LOCK(random_state_lock);

  current_state.v[0]=(seed & RANDOM_RAND_MAX);

  for(i=1; i<RANDOM_NUM_STATE_VALS; i++)
    current_state.v[i] = (RANDOM_LC_ALPHA * current_state.v[i-1]
                          + RANDOM_LC_BETA) & RANDOM_RAND_MAX;

  current_state.j = 0;
  current_state.k = RANDOM_MM_ALPHA-RANDOM_MM_BETA;
  current_state.x = RANDOM_MM_ALPHA-0;

  THREAD_UNLOCK(random_state_lock);

  return;
  } 
开发者ID:versionzero,项目名称:gaul,代码行数:30,代码来源:random_util.c

示例6: openlog

void
openlog(const char *ident, int logstat, int logfac)
{
	THREAD_LOCK();
	openlog_unlocked(ident, logstat, logfac);
	THREAD_UNLOCK();
}
开发者ID:5432935,项目名称:crossbridge,代码行数:7,代码来源:syslog.c

示例7: getlogin_basic

static char *
getlogin_basic(int *status)
{
	static char logname[MAXLOGNAME];

	if (_logname_valid == 0) {
#ifdef __NETBSD_SYSCALLS
		if (__getlogin(logname, sizeof(logname) - 1) < 0) {
#else
		if (_getlogin(logname, sizeof(logname)) < 0) {
#endif
			*status = errno;
			return (NULL);
		}
		_logname_valid = 1;
	}
	*status = 0;
	return (*logname ? logname : NULL);
}

char *
getlogin(void)
{
	char	*result;
	int	status;

	THREAD_LOCK();
	result = getlogin_basic(&status);
	THREAD_UNLOCK();
	return (result);
}
开发者ID:AhmadTux,项目名称:freebsd-ports,代码行数:31,代码来源:getlogin.c

示例8: event_enable_write

static void event_enable_write(ACL_EVENT *eventp, ACL_VSTREAM *stream,
	int timeout, ACL_EVENT_NOTIFY_RDWR callback, void *context)
{
	const char *myname = "event_enable_write";
	EVENT_POLL_THR *event_thr = (EVENT_POLL_THR *) eventp;
	ACL_EVENT_FDTABLE *fdp;
	ACL_SOCKET sockfd;

	sockfd = ACL_VSTREAM_SOCK(stream);
	fdp = (ACL_EVENT_FDTABLE*) stream->fdp;
	if (fdp == NULL) {
		fdp = event_fdtable_alloc();
		fdp->listener = 0;
		fdp->stream = stream;
		stream->fdp = (void *) fdp;
	} else if (fdp->flag & EVENT_FDTABLE_FLAG_READ)
		acl_msg_panic("%s(%d)->%s: fd %d: multiple I/O request",
			__FILE__, __LINE__, myname, sockfd);
	else {
		fdp->listener = 0;
		fdp->stream = stream;
	}

	if (fdp->w_callback != callback || fdp->w_context != context) {
		fdp->w_callback = callback;
		fdp->w_context = context;
	}

	if (timeout > 0) {
		fdp->w_timeout = timeout * 1000000;
		fdp->w_ttl = eventp->present + fdp->w_timeout;
	} else {
		fdp->w_ttl = 0;
		fdp->w_timeout = 0;
	}

	if ((fdp->flag & EVENT_FDTABLE_FLAG_WRITE) != 0)
		return;

	stream->nrefer++;
	fdp->flag = EVENT_FDTABLE_FLAG_WRITE | EVENT_FDTABLE_FLAG_EXPT;

	THREAD_LOCK(&event_thr->event.tb_mutex);

	fdp->fdidx = eventp->fdcnt;
	eventp->fdtabs[eventp->fdcnt++] = fdp;

	event_thr->fds[fdp->fdidx].fd = sockfd;
	event_thr->fds[fdp->fdidx].events = POLLOUT | POLLHUP | POLLERR;
	if (eventp->maxfd == ACL_SOCKET_INVALID || eventp->maxfd < sockfd)
		eventp->maxfd = sockfd;

	acl_fdmap_add(event_thr->fdmap, sockfd, fdp);

	THREAD_UNLOCK(&event_thr->event.tb_mutex);

	if (event_thr->event.blocked && event_thr->event.evdog
	    && event_dog_client(event_thr->event.evdog) != stream)
		event_dog_notify(event_thr->event.evdog);
}
开发者ID:2202877,项目名称:acl,代码行数:60,代码来源:events_poll_thr.c

示例9: arc4random_stir

void
arc4random_stir(void)
{
	THREAD_LOCK();
	arc4_check_init();
	arc4_stir();
	rs_stired = 1;
	THREAD_UNLOCK();
}
开发者ID:asdlei00,项目名称:freebsd,代码行数:9,代码来源:arc4random.c

示例10: arc4random_addrandom

void
arc4random_addrandom(u_char *dat, int datlen)
{
	THREAD_LOCK();
	arc4_check_init();
	arc4_check_stir();
	arc4_addrandom(dat, datlen);
	THREAD_UNLOCK();
}
开发者ID:asdlei00,项目名称:freebsd,代码行数:9,代码来源:arc4random.c

示例11: avltree_node_free

static void avltree_node_free(AVLNode *node)
  {
  THREAD_LOCK(avltree_node_buffer_lock);
  node->right = node_free_list;
  node_free_list = node;
  THREAD_UNLOCK(avltree_node_buffer_lock);

  return;
  }
开发者ID:versionzero,项目名称:gaul,代码行数:9,代码来源:avltree.c

示例12: __sfp

/*
 * Find a free FILE for fopen et al.
 */
FILE *
__sfp(void)
{
	FILE	*fp;
	int	n;
	struct glue *g;

	if (!__sdidinit)
		__sinit();
	/*
	 * The list must be locked because a FILE may be updated.
	 */
	THREAD_LOCK();
	for (g = &__sglue; g != NULL; g = g->next) {
		for (fp = g->iobs, n = g->niobs; --n >= 0; fp++)
			if (fp->pub._flags == 0)
				goto found;
	}
	THREAD_UNLOCK();	/* don't hold lock while malloc()ing. */
	if ((g = moreglue(NDYNAMIC)) == NULL)
		return (NULL);
	THREAD_LOCK();		/* reacquire the lock */
	SET_GLUE_PTR(lastglue->next, g); /* atomically append glue to list */
	lastglue = g;		/* not atomic; only accessed when locked */
	fp = g->iobs;
found:
	fp->pub._flags = 1;	/* reserve this slot; caller sets real flags */
	THREAD_UNLOCK();
	fp->pub._p = NULL;	/* no current pointer */
	fp->pub._w = 0;		/* nothing to read or write */
	fp->pub._r = 0;
	fp->_bf._base = NULL;	/* no buffer */
	fp->_bf._size = 0;
	fp->pub._lbfsize = 0;	/* not line buffered */
	fp->pub._fileno = -1;	/* no file */
/*	fp->_cookie = <any>; */	/* caller sets cookie, _read/_write etc */
	fp->_ub._base = NULL;	/* no ungetc buffer */
	fp->_ub._size = 0;
	fp->_lb._base = NULL;	/* no line buffer */
	fp->_lb._size = 0;
/*	fp->_lock = NULL; */	/* once set always set (reused) */
	memset(WCIO_GET(fp), 0, sizeof(struct wchar_io_data));
	return (fp);
}
开发者ID:kusumi,项目名称:DragonFlyBSD,代码行数:47,代码来源:findfp.c

示例13: closelog

void
closelog(void)
{
	THREAD_LOCK();
	(void)_close(LogFile);
	LogFile = -1;
	LogTag = NULL;
	status = NOCONN;
	THREAD_UNLOCK();
}
开发者ID:5432935,项目名称:crossbridge,代码行数:10,代码来源:syslog.c

示例14: getlogin

char *
getlogin(void)
{
	char	*result;
	int	status;

	THREAD_LOCK();
	result = getlogin_basic(&status);
	THREAD_UNLOCK();
	return (result);
}
开发者ID:AhmadTux,项目名称:freebsd,代码行数:11,代码来源:getlogin.c

示例15: random_get_state_wrapper

int random_get_state_wrapper(void)
  {
  int	stateid;	/* State handle. */

  THREAD_LOCK(state_table_lock);
  if (!state_table) state_table=table_new();

  stateid = table_add(state_table, (vpointer) current_state);	/* FIXME: Need to copy state. */
  THREAD_UNLOCK(state_table_lock);

  return stateid;
  }
开发者ID:versionzero,项目名称:gaul,代码行数:12,代码来源:random_util.c


注:本文中的THREAD_UNLOCK函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。