• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ pthread_rwlock_init函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: run

    void run() {
/**
 * note: this test will deadlock if the code breaks
 */

#if defined(__linux__) || defined(__APPLE__)

        // create
        pthread_rwlock_t lk;
        verify(pthread_rwlock_init(&lk, 0) == 0);

        // read lock
        verify(pthread_rwlock_rdlock(&lk) == 0);

        AtomicUInt32 x1(0);
        stdx::thread t1(stdx::bind(worker1, &lk, &x1));
        while (!x1.load())
            ;
        verify(x1.load() == 1);
        sleepmillis(500);
        verify(x1.load() == 1);

        AtomicUInt32 x2(0);

        stdx::thread t2(stdx::bind(worker2, &lk, &x2));
        t2.join();
        verify(x2.load() == 1);

        pthread_rwlock_unlock(&lk);

        for (int i = 0; i < 2000; i++) {
            if (x1.load() == 2)
                break;
            sleepmillis(1);
        }

        verify(x1.load() == 2);
        t1.join();
#endif
    }
开发者ID:stevelyall,项目名称:mongol-db,代码行数:40,代码来源:threadedtests.cpp


示例2: SpriteList

Region::Region(Palette* p, int i) {

	spritelist = new SpriteList();

	id = i;
	name = "";
	SetTypeAndSid(UNKNOWN, 0, 0);

	_loop = NULL;
	_disableNotes = false;

	palette = p;
	_lastScheduled = -1;
	_chording = false;
	_looping = DEFAULT_LOOPING;

	NosuchLockInit(&_region_mutex,"region");
	// spritelist_rwlock = PTHREAD_RWLOCK_INITIALIZER;
	cursorlist_rwlock = PTHREAD_RWLOCK_INITIALIZER;
	// int rc1 = pthread_rwlock_init(&spritelist_rwlock, NULL);
	int rc = pthread_rwlock_init(&cursorlist_rwlock, NULL);
	if ( rc ) {
		NosuchDebug("Failure on pthread_rwlock_init!? rc=%d",rc);
	}

	_latestNoteTime = 0;
	x_min = 0.00f;
	y_min = 0.00f;
	x_max = 1.0f;
	y_max = 1.0f;
	_channel = -1;

	PaletteHost* ph = p->paletteHost();
	_graphicBehaviour = ph->makeGraphicBehaviour(this);
	_musicBehaviour = ph->makeMusicBehaviour(this);

	_noteBehaviour = new NoteBehaviourDefault(this);

	initParams();
}
开发者ID:nosuchtim,项目名称:MMTT1,代码行数:40,代码来源:Region.cpp


示例3: TEST

TEST(sfrlock, uncontended_write_cost) {
  double t;
  double r;
  pthread_mutex_t mutex;
  pthread_rwlock_t rwlock;
  sfrlock_t sfrlock;

  sfrlock_init(&sfrlock);
  pthread_rwlock_init(&rwlock, nullptr);
  pthread_mutex_init(&mutex, nullptr);

  r = measure_time([&] () {
        for (unsigned cnt = repeat; cnt; cnt--) {
          sfrlock_wrlock(&sfrlock);
          sfrlock_wrunlock(&sfrlock);
        }
      });
  printf("sfrlock_t time: %lf ms\n", r / 1e6);

  t = measure_time([&] () {
        for (unsigned cnt = repeat; cnt; cnt--) {
          pthread_rwlock_wrlock(&rwlock);
          pthread_rwlock_unlock(&rwlock);
        }
      });
  printf("pthread_rwlock_t time: %lf ms (%+.2lf%%)\n", t / 1e6,
         -(1 - (t / r)) * 100);

  t = measure_time([&] () {
        for (unsigned cnt = repeat; cnt; cnt--) {
          pthread_mutex_lock(&mutex);
          pthread_mutex_unlock(&mutex);
        }
      });
  printf("pthread_mutex_t time: %lf ms (%+.2lf%%)\n", t / 1e6,
         -(1 - (t / r)) * 100);

  pthread_rwlock_destroy(&rwlock);
  pthread_mutex_destroy(&mutex);
}
开发者ID:247687009,项目名称:mcrouter,代码行数:40,代码来源:sfrlock_test.cpp


示例4: _magic

ESFReadWriteLock::ESFReadWriteLock() :
    _magic(0) {
#ifdef HAVE_PTHREAD_RWLOCK_INIT

    if (0 == pthread_rwlock_init(&_lock, 0)) {
        _magic = ESF_MAGIC;
    }

#elif defined HAVE_PTHREAD_MUTEX_INIT && defined HAVE_PTHREAD_COND_INIT && \
      defined HAVE_PTHREAD_MUTEX_DESTROY && defined HAVE_PTHREAD_COND_DESTROY

    if ( 0 != pthread_mutex_init( &_lock._mutex, 0 ) )
    {
        return;
    }

    if ( 0 != pthread_cond_init( &_lock._readSignal, 0 ) )
    {
        pthread_mutex_destroy( &_lock._mutex );
        return;
    }

    if ( 0 != pthread_cond_init( &_lock._writeSignal, 0 ) )
    {
        pthread_mutex_destroy( &_lock._mutex );
        pthread_cond_destroy( &_lock._readSignal );
        return;
    }

    _lock._readersActive = 0;
    _lock._readersWaiting = 0;
    _lock._writersActive = 0;
    _lock._writersWaiting = 0;

    _magic = ESF_MAGIC;

#else
#error "Platform has no rw lock initializer"
#endif
}
开发者ID:duderino,项目名称:rilakkuma,代码行数:40,代码来源:ESFReadWriteLock.cpp


示例5: dt_control_init

void dt_control_init(dt_control_t *s)
{
  memset(s->vimkey, 0, sizeof(s->vimkey));
  s->vimkey_cnt = 0;

  // same thread as init
  s->gui_thread = pthread_self();

  // initialize static mutex
  dt_pthread_mutex_init(&_control_gdk_lock_threads_mutex, NULL);

  // s->last_expose_time = dt_get_wtime();
  s->key_accelerators_on = 1;
  s->log_pos = s->log_ack = 0;
  s->log_busy = 0;
  s->log_message_timeout_id = 0;
  dt_pthread_mutex_init(&(s->log_mutex), NULL);
  s->progress = 200.0f;

  dt_conf_set_int("ui_last/view", DT_MODE_NONE);

  pthread_cond_init(&s->cond, NULL);
  dt_pthread_mutex_init(&s->cond_mutex, NULL);
  dt_pthread_mutex_init(&s->queue_mutex, NULL);
  dt_pthread_mutex_init(&s->run_mutex, NULL);
  pthread_rwlock_init(&s->xprofile_lock, NULL);
  dt_pthread_mutex_init(&(s->global_mutex), NULL);
  dt_pthread_mutex_init(&(s->progress_system.mutex), NULL);

  // start threads
  dt_control_jobs_init(s);

  s->button_down = 0;
  s->button_down_which = 0;
  s->mouse_over_id = -1;
  s->dev_closeup = 0;
  s->dev_zoom_x = 0;
  s->dev_zoom_y = 0;
  s->dev_zoom = DT_ZOOM_FIT;
}
开发者ID:powentan,项目名称:darktable,代码行数:40,代码来源:control.c


示例6: dnscacheInit

/* init function (must be called once) */
rsRetVal
dnscacheInit(void)
{
    DEFiRet;
    if((dnsCache.ht = create_hashtable(100, hash_from_key_fn, key_equals_fn,
                                       (void(*)(void*))entryDestruct)) == NULL) {
        DBGPRINTF("dnscache: error creating hash table!\n");
        ABORT_FINALIZE(RS_RET_ERR); // TODO: make this degrade, but run!
    }
    dnsCache.nEntries = 0;
    pthread_rwlock_init(&dnsCache.rwlock, NULL);
    CHKiRet(objGetObjInterface(&obj)); /* this provides the root pointer for all other queries */
    CHKiRet(objUse(glbl, CORE_COMPONENT));
    CHKiRet(objUse(errmsg, CORE_COMPONENT));
    CHKiRet(objUse(prop, CORE_COMPONENT));

    prop.Construct(&staticErrValue);
    prop.SetString(staticErrValue, (uchar*)"???", 3);
    prop.ConstructFinalize(staticErrValue);
finalize_it:
    RETiRet;
}
开发者ID:madedotcom,项目名称:rsyslog,代码行数:23,代码来源:dnscache.c


示例7: debug

DICTIONARY *dictionary_create(uint32_t flags) {
	debug(D_DICTIONARY, "Creating dictionary.");

	DICTIONARY *dict = calloc(1, sizeof(DICTIONARY));
	if(unlikely(!dict)) fatal("Cannot allocate DICTIONARY");

	if(flags & DICTIONARY_FLAG_WITH_STATISTICS) {
		dict->stats = calloc(1, sizeof(struct dictionary_stats));
		if(!dict->stats) fatal("Cannot allocate statistics for DICTIONARY");
	}

	if(!(flags & DICTIONARY_FLAG_SINGLE_THREADED)) {
		dict->rwlock = calloc(1, sizeof(pthread_rwlock_t));
		if(!dict->rwlock) fatal("Cannot allocate pthread_rwlock_t for DICTIONARY");
		pthread_rwlock_init(dict->rwlock, NULL);
	}

	avl_init(&dict->values_index, name_value_compare);
	dict->flags = flags;

	return dict;
}
开发者ID:Lxg1582,项目名称:netdata,代码行数:22,代码来源:dictionary.c


示例8: main

int main(int argc, char *argv[])
{
    L = atol(argv[1]);
    K = atol(argv[2]);
    M = atol(argv[3]);

    if (signal(SIGINT, exit_server) == SIG_ERR)
        syserr("Error in signal (SIGINT)");

    init_queues();

    int thr_err;
    pthread_t thread_id;
    make_attr_detached();
    if (thr_err = pthread_rwlock_init(&rwlock, NULL))
        syserr_ext(thr_err, "Error in function pthread_rwlock_init");

    Mesg mesg;
    int bytes_rcvd;
    while (1)
    {
        if ((bytes_rcvd = msgrcv(msg_rcv_id, &mesg, MAX_BUFF, 0, 0)) <= 0)
            syserr("Error in msgrcv (receiving type(pid))");
        mesg.mesg_data[bytes_rcvd] = '\0';

        if (mesg.mesg_type == READ_TYPE_KOM)
        {
            if ((thr_err = pthread_create(&thread_id, &attr, serve_committee, &mesg.mesg_data)) != 0)
                syserr_ext(thr_err, "Error in pthread_create (for serve_committee)");
        }
        else
        {
            if ((thr_err = pthread_create(&thread_id, &attr, serve_report, &mesg.mesg_data)) != 0)
                syserr_ext(thr_err, "Error in pthread_create (for serve_report)");
        }
    }

    exit_server(0);
}
开发者ID:Solmis,项目名称:SO,代码行数:39,代码来源:serwer.c


示例9: init_read_write_lock

static void
init_read_write_lock(pthread_rwlock_t* lock)
{
    pthread_rwlockattr_t* pattr;
#if defined(YOG_HAVE_PTHREAD_RWLOCKATTR_INIT)
    pthread_rwlockattr_t attr;
    pthread_rwlockattr_init(&attr);
#   if defined(YOG_HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP)
    pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NP);
#   endif
    pattr = &attr;
#else
    pattr = NULL;
#endif
    int err;
    if ((err = pthread_rwlock_init(lock, pattr)) != 0) {
        YOG_BUG(NULL, "pthread_rwlock_init failed: %s", strerror(err));
    }
#if defined(YOG_HAVE_PTHREAD_RWLOCKATTR_INIT) && defined(YOG_HAVE_PTHREAD_RWLOCKATTR_DESTROY)
    pthread_rwlockattr_destroy(&attr);
#endif
}
开发者ID:SumiTomohiko,项目名称:Yog,代码行数:22,代码来源:vm.c


示例10: diskfs_user_make_node

/* The user must define this function if she wants to use the node
   cache.  Create and initialize a node.  */
error_t
diskfs_user_make_node (struct node **npp, struct lookup_context *ctx)
{
  struct node *np;
  struct disknode *dn;

  /* Create the new node.  */
  np = diskfs_make_node_alloc (sizeof *dn);
  if (np == NULL)
    return ENOMEM;

  /* Format specific data for the new node.  */
  dn = diskfs_node_disknode (np);
  dn->dirents = 0;
  dn->dir_idx = 0;
  dn->pager = 0;
  pthread_rwlock_init (&dn->alloc_lock, NULL);
  pokel_init (&dn->indir_pokel, diskfs_disk_pager, disk_cache);

  *npp = np;
  return 0;
}
开发者ID:lenconda,项目名称:hurd,代码行数:24,代码来源:inode.c


示例11: main

int main(int argc, char** argv)
{
  pthread_t thread1;
  pthread_t thread2;

#if 0

  VALGRIND_DO_CLIENT_REQUEST_STMT(VG_USERREQ__DRD_TRACE_ADDR,
                                  &s_racy, 0, 0, 0, 0, 0);
#endif

  pthread_rwlock_init(&s_rwlock, 0);
  pthread_create(&thread1, 0, thread_func, 0);
  pthread_create(&thread2, 0, thread_func, 0);
  pthread_join(thread1, 0);
  pthread_join(thread2, 0);
  pthread_rwlock_destroy(&s_rwlock);

  fprintf(stderr, "Result: %d\n", s_racy);

  return 0;
}
开发者ID:bluca,项目名称:valgrind-dpdk,代码行数:22,代码来源:rwlock_race.c


示例12: main

int main(int argc, char **argv)
{
	int retval, i;

	pthread_t writer_id, reader_id;
	pthread_attr_t attr;
	int nreadercount = 1, nwritercount = 1;

	if (argc != 2) {
		fprintf(stderr, "usage, <%s threadcount>", argv[0]);
		return -1;
	}
	retval = pthread_rwlock_init(&rwlock, NULL);
	if (retval) {
		fprintf(stderr, "init lock failed\n");
		return retval;
	}
	pthread_attr_init(&attr);
	//pthread_attr_setdetachstate用来设置线程的分离状态
	//也就是说一个线程怎么样终止自己,状态设置为PTHREAD_CREATE_DETACHED
	//表示以分离状态启动线程
	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
	
	//分别在main函数中对读出者和写入者加锁,得到的处理结果是不一样的
	pthread_rwlock_wrlock(&rwlock);
//	pthread_rwlock_rdlock(&rwlock);
	for (i = 0; i < atoi(argv[1]); i++) {
		if (random() % 2) {
			pthread_create(&reader_id, &attr, readers, (void *)nreadercount);
			printf("create reader %d\n", nreadercount++);
		} else {
			pthread_create(&writer_id, &attr, writers, (void *)nwritercount);
			printf("create writer %d\n", nwritercount++);
		}
	}
	pthread_rwlock_unlock(&rwlock);
	sleep(20);//sleep是为了等待另外的线程的执行
	return 0;	
}
开发者ID:ZombieTerminator,项目名称:LINUX_IPC,代码行数:39,代码来源:pthread_rwlock_test2.c


示例13: init_mapping

int init_mapping()
{
	int i;
	for (i = 0; i < MAP_TABLE_SIZE; i++) {
		memset(&(ip_map_table[i]), 0, sizeof(struct ip_map_table_node));
		if (pthread_rwlock_init(&(ip_map_table[i].rwlock), NULL) != 0) {
			fprintf(stderr, "Error initialize mutex for map-table\n");
			return(1);
		}
	}
	for (i = 0; i < HASH_TABLE_SIZE; i++) {
		memset(&(hash_table[i]), 0, sizeof(struct hash_table_array_node));
		if (pthread_mutex_init(&(hash_table[i].mutex), NULL) != 0) {
			fprintf(stderr, "Error initialize mutex for hash-table\n");
			return(1);
		}
	}
	for (i = 0; i < VSERVER_MAXSIZE; i++) {
		memset(&(vserver_list[i]), 0, sizeof(struct vserver_list_node));
	}
	return(0);
}
开发者ID:jiangqihua,项目名称:natlite,代码行数:22,代码来源:natlite.c


示例14: fs_file_handle_create

// create a file handle from an fs_entry
struct fs_file_handle* fs_file_handle_create( struct fs_core* core, struct fs_entry* ent, char const* opened_path, uint64_t parent_id, char const* parent_name ) {
    struct fs_file_handle* fh = SG_CALLOC( struct fs_file_handle, 1 );
    fh->flags = 0;
    fh->open_count = 0;
    fh->fent = ent;
    fh->volume = ent->volume;
    fh->file_id = ent->file_id;
    fh->path = strdup( opened_path );
    fh->parent_name = strdup( parent_name );
    fh->parent_id = parent_id;
    fh->transfer_timeout_ms = (core->conf->transfer_timeout) * 1000L;
    fh->dirty = false;

    uint64_t gateway_type = ms_client_get_gateway_type( core->ms, ent->coordinator );
    if( gateway_type == SYNDICATE_AG ) {
        fh->is_AG = true;
    }

    pthread_rwlock_init( &fh->lock, NULL );

    return fh;
}
开发者ID:pombredanne,项目名称:syndicate,代码行数:23,代码来源:open.cpp


示例15: tpclog_init

/* Initialize TPCLog LOG to use the provided DIRNAME to store its associated
 * entries. Sets LOG's NEXTID field based on the entries that currently exist
 * in DIRNAME. */
int tpclog_init(tpclog_t *log, char *dirname) {
  struct stat st;
  unsigned long nextid = 0;
  char filename[MAX_FILENAME];
  if (stat(dirname, &st) == -1) {
    if (mkdir(dirname, 0700) == -1)
      return errno;
  }
  log->dirname = malloc(strlen(dirname) + 1);
  if (!log->dirname)
    fatal_malloc();
  strcpy(log->dirname, dirname);
  pthread_rwlock_init(&log->lock, NULL);

  /* Iterate through entries to determine next available ID, since this log may
   * be recovering from a crash. */
  sprintf(filename, "%s/%lu%s", log->dirname, nextid++, TPCLOG_FILETYPE);
  while (stat(filename, &st) != -1)
    sprintf(filename, "%s/%lu%s", log->dirname, nextid++, TPCLOG_FILETYPE);
  log->nextid = nextid - 1;
  return 0;
}
开发者ID:CMH317,项目名称:Berkeley-CS162,代码行数:25,代码来源:tpclog.c


示例16: main

int main(void)
{
	int i;

	thread = (void *)malloc(NTASKS*sizeof(pthread_t));
	task = (void *)malloc(NTASKS*sizeof(RT_TASK *));
	pthread_setschedparam_np(2*NTASKS, SCHED_FIFO, 0, 0x1, PTHREAD_HARD_REAL_TIME_NP);
	pthread_rwlock_init(rwl = &rwls, 0);
	pthread_barrier_init(&barrier, NULL, NTASKS + 1);
	rt_set_oneshot_mode();
	start_rt_timer(0);
	for (i = 0; i < NTASKS; i++) {
		pthread_create(&thread[i], NULL, (void *)thread_fun, (void *)(i + 1));
	}
	pthread_barrier_wait(&barrier);
	pthread_rwlock_destroy(rwl);
	pthread_barrier_destroy(&barrier);
	stop_rt_timer();
	free(thread);
	free(task);
	return 0;
}
开发者ID:cjecho,项目名称:RTAI,代码行数:22,代码来源:rwlocks.c


示例17: lagopus_rwlock_reinitialize

lagopus_result_t
lagopus_rwlock_reinitialize(lagopus_rwlock_t *rwlptr) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;

  if (rwlptr != NULL &&
      *rwlptr != NULL) {
    int st;

    errno = 0;
    if ((st = pthread_rwlock_init(&((*rwlptr)->m_rwl), NULL)) == 0) {
      (*rwlptr)->m_prev_cancel_state = -INT_MAX;
      ret = LAGOPUS_RESULT_OK;
    } else {
      errno = st;
      ret = LAGOPUS_RESULT_POSIX_API_ERROR;
    }
  } else {
    ret = LAGOPUS_RESULT_INVALID_ARGS;
  }

  return ret;
}
开发者ID:AkiraSuu,项目名称:lagopus,代码行数:22,代码来源:lock.c


示例18: tc_device_index_find

static struct tc_device *tc_device_create(char *id)
{
	struct tc_device *d = tc_device_index_find(id, 0);

	if(!d) {
		debug(D_TC_LOOP, "TC: Creating device '%s'", id);

		d = calloc(1, sizeof(struct tc_device));
		if(!d) {
			fatal("Cannot allocate memory for tc_device %s", id);
			return NULL;
		}

		d->id = strdup(id);
		d->hash = simple_hash(d->id);

		d->classes_index.root = NULL;
		d->classes_index.compar = tc_class_compare;
#ifdef AVL_LOCK_WITH_MUTEX
		pthread_mutex_init(&d->classes_index.mutex, NULL);
#else
		pthread_rwlock_init(&d->classes_index.rwlock, NULL);
#endif

		tc_device_index_add(d);

		if(!tc_device_root) {
			tc_device_root = d;
		}
		else {
			d->next = tc_device_root;
			tc_device_root->prev = d;
			tc_device_root = d;
		}
	}

	return(d);
}
开发者ID:2-B,项目名称:netdata,代码行数:38,代码来源:plugin_tc.c


示例19: ptw32_rwlock_check_need_init

int
ptw32_rwlock_check_need_init (pthread_rwlock_t * rwlock)
{
    int result = 0;
    ptw32_mcs_local_node_t node;

    /*
     * The following guarded test is specifically for statically
     * initialised rwlocks (via PTHREAD_RWLOCK_INITIALIZER).
     */
    ptw32_mcs_lock_acquire(&ptw32_rwlock_test_init_lock, &node);

    /*
     * We got here possibly under race
     * conditions. Check again inside the critical section
     * and only initialise if the rwlock is valid (not been destroyed).
     * If a static rwlock has been destroyed, the application can
     * re-initialise it only by calling pthread_rwlock_init()
     * explicitly.
     */
    if (*rwlock == PTHREAD_RWLOCK_INITIALIZER)
    {
        result = pthread_rwlock_init (rwlock, NULL);
    }
    else if (*rwlock == NULL)
    {
        /*
         * The rwlock has been destroyed while we were waiting to
         * initialise it, so the operation that caused the
         * auto-initialisation should fail.
         */
        result = EINVAL;
    }

    ptw32_mcs_lock_release(&node);

    return result;
}
开发者ID:nail,项目名称:node,代码行数:38,代码来源:ptw32_rwlock_check_need_init.c


示例20: main

int main(int argc, char** argv) {
	signal(SIGINT, stopHandler); /* catches ctrl-c */
#ifdef UA_MULTITHREADING
	pthread_rwlock_init(&writeLock, 0);
#endif

	UA_Server *server = UA_Server_new(UA_ServerConfig_standard);
	logger = Logger_Stdout_new();
	UA_Server_setLogger(server, logger);
    UA_ByteString certificate = loadCertificate();
    UA_Server_setServerCertificate(server, certificate);
    UA_ByteString_deleteMembers(&certificate);
	UA_Server_addNetworkLayer(server, ServerNetworkLayerTCP_new(UA_ConnectionConfig_standard, 16664));

	// add node with the datetime data source
	UA_DataSource dateDataSource = (UA_DataSource)
        {.handle = NULL,
		.read = readTimeData,
		.release = releaseTimeData,
		.write = NULL};
	const UA_QualifiedName dateName = UA_QUALIFIEDNAME(1, "current time");
	UA_Server_addDataSourceVariableNode(server, dateDataSource, dateName, UA_NODEID_NULL,
                                        UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
                                        UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES));

	//cpu temperature monitoring for linux machines
	if((temperatureFile = fopen("/sys/class/thermal/thermal_zone0/temp", "r"))){
		// add node with the data source
		UA_DataSource temperatureDataSource = (UA_DataSource)
    	    {.handle = NULL,
			.read = readTemperature,
			.release = releaseTemperature,
			.write = NULL};
		const UA_QualifiedName tempName = UA_QUALIFIEDNAME(1, "cpu temperature");
		UA_Server_addDataSourceVariableNode(server, temperatureDataSource, tempName, UA_NODEID_NULL,
                                            UA_NODEID_NUMERIC(0, UA_NS0ID_OBJECTSFOLDER),
                                            UA_NODEID_NUMERIC(0, UA_NS0ID_ORGANIZES));
	}
开发者ID:hfaham,项目名称:open62541,代码行数:38,代码来源:server.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ pthread_rwlock_rdlock函数代码示例发布时间:2022-05-30
下一篇:
C++ pthread_rwlock_destroy函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap