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

C++ pthread_mutex_destroy函数代码示例

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

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



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

示例1: pthread_mutex_destroy

 MutexImpementation::~MutexImpementation(void) {
     pthread_mutex_destroy(&Pmutex);
 }
开发者ID:kn1m,项目名称:Lab4-AK,代码行数:3,代码来源:thread_implementation.cpp


示例2: pthread_mutex_destroy

 Mutex::~Mutex() {
     pthread_mutex_destroy(&mutex);
 }
开发者ID:alidugan,项目名称:hazelcast-cpp-client,代码行数:3,代码来源:Mutex.cpp


示例3: mssync_destroy

void mssync_destroy(struct mssync *s)
{
    pthread_mutex_destroy(&(s->lock));
}
开发者ID:bigclean,项目名称:moc,代码行数:4,代码来源:mscli.c


示例4: report_error

QMutexPrivate::~QMutexPrivate()
{
    report_error(pthread_cond_destroy(&cond), "QMutex", "cv destroy");
    report_error(pthread_mutex_destroy(&mutex), "QMutex", "mutex destroy");
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:5,代码来源:qmutex_unix.cpp


示例5: main

int main(int argc, char *argv[])
{
	int timeout = 0;
	sp_error error;
	int notify_cmdline = 0;
	int notify_events = 0;
	struct timespec ts;
	
	(void)argc;
	(void)argv;

	pthread_mutex_init(&g_notify_mutex, NULL);
	pthread_cond_init(&g_notify_cond, NULL);
	session_init();
	cmd_init(cmd_notify);
	
	do {
		clock_gettime(CLOCK_REALTIME, &ts);
		ts.tv_sec += timeout / 1000;
		ts.tv_nsec += (timeout % 1000) * 1E6;
		if (ts.tv_nsec > 1E9) {
			ts.tv_sec++;
			ts.tv_nsec -= 1E9;
		}

		pthread_mutex_lock(&g_notify_mutex);
		pthread_cond_timedwait(&g_notify_cond, &g_notify_mutex, &ts);
		notify_cmdline = g_notify_cmdline;
		notify_events = g_notify_events;
		g_notify_cmdline = 0;
		g_notify_events = 0;
		pthread_mutex_unlock(&g_notify_mutex);
		if (notify_cmdline) {
			cmd_process();
		}

		if (notify_events) {
			do {
				error = sp_session_process_events(g_session, &timeout);
				if (error != SP_ERROR_OK)
					fprintf(stderr, "error processing events: %s\n",
							sp_error_message(error));
			} while (timeout == 0);
		}

	} while (!is_program_finished());

	session_logout();
	while (session_is_logged_in()) {
       		clock_gettime(CLOCK_REALTIME, &ts);
		ts.tv_sec += 1;

		pthread_mutex_lock(&g_notify_mutex);
		pthread_cond_timedwait(&g_notify_cond, &g_notify_mutex, &ts);
		notify_events = g_notify_events;
		g_notify_events = 0;
		pthread_mutex_unlock(&g_notify_mutex);
		if (notify_events) {
			do {
				error = sp_session_process_events(g_session, &timeout);
				if (error != SP_ERROR_OK)
					fprintf(stderr, "error processing events: %s\n",
							sp_error_message(error));
			} while (timeout == 0);
		}
	}

	session_release();
	cmd_destroy();

	pthread_mutex_destroy(&g_notify_mutex);
	pthread_cond_destroy(&g_notify_cond);

	return 0;

}
开发者ID:iceaway,项目名称:libspotify-client,代码行数:76,代码来源:session.c


示例6: vcos_timer_create

VCOS_STATUS_T vcos_timer_create(VCOS_TIMER_T *timer,
                                const char *name,
                                void (*expiration_routine)(void *context),
                                void *context)
{
   pthread_mutexattr_t lock_attr;
   VCOS_STATUS_T result = VCOS_SUCCESS;
   int settings_changed_initialized = 0;
   int lock_attr_initialized = 0;
   int lock_initialized = 0;

   (void)name;

   vcos_assert(timer);
   vcos_assert(expiration_routine);

   memset(timer, 0, sizeof(VCOS_TIMER_T));

   timer->orig_expiration_routine = expiration_routine;
   timer->orig_context = context;

   /* Create conditional variable for notifying the timer's thread
    * when settings change.
    */
   if (result == VCOS_SUCCESS)
   {
      int rc = pthread_cond_init(&timer->settings_changed, NULL);
      if (rc == 0)
         settings_changed_initialized = 1;
      else
         result = vcos_pthreads_map_error(rc);
   }

   /* Create attributes for the lock (we want it to be recursive) */
   if (result == VCOS_SUCCESS)
   {
      int rc = pthread_mutexattr_init(&lock_attr);
      if (rc == 0)
      {
         pthread_mutexattr_settype(&lock_attr, PTHREAD_MUTEX_RECURSIVE);
         lock_attr_initialized = 1;
      }
      else
      {
         result = vcos_pthreads_map_error(rc);
      }
   }

   /* Create lock for the timer structure */
   if (result == VCOS_SUCCESS)
   {
      int rc = pthread_mutex_init(&timer->lock, &lock_attr);
      if (rc == 0)
         lock_initialized = 1;
      else
         result = vcos_pthreads_map_error(rc);
   }

   /* Lock attributes are no longer needed */
   if (lock_attr_initialized)
      pthread_mutexattr_destroy(&lock_attr);

   /* Create the underlying thread */
   if (result == VCOS_SUCCESS)
   {
      int rc = pthread_create(&timer->thread, NULL, _timer_thread, timer);
      if (rc != 0)
         result = vcos_pthreads_map_error(rc);
   }

   /* Clean up if anything went wrong */
   if (result != VCOS_SUCCESS)
   {
      if (lock_initialized)
         pthread_mutex_destroy(&timer->lock);

      if (settings_changed_initialized)
         pthread_cond_destroy(&timer->settings_changed);
   }

   return result;
}
开发者ID:Allroad,项目名称:userland,代码行数:82,代码来源:vcos_pthreads.c


示例7: agent


//.........这里部分代码省略.........
                if (IS_AM_ERROR(inMessage.type)) {
                        if (inMessage.type & AM_AVATAR_OUT_OF_TURN)
                                continue;
                        printAMError(fd_log, inMessage.type);
                        shmctl(shmid, IPC_RMID, NULL);
                        return -1;
                }
                /* if the message is not the right type */
                if (!(inMessage.type & AM_AVATAR_TURN))
                        continue;

                /* if it is our turn */
                if (inMessage.avatar_turn.TurnId == curAvatar) {
                        pthread_mutex_lock(&globalmap->mapMutex);
                        /* Get our next move */
                        movdir = getNextMove(*globalmap, inMessage.avatar_turn.Pos,
                                        movdir, pos[curAvatar], nAvatars, curAvatar,
                                        algo);

                        /* initialize outMessage */
                        memset(&outMessage, 0, sizeof(outMessage));
                        outMessage.type = AM_AVATAR_MOVE;
                        outMessage.avatar_move.AvatarId = curAvatar;
                        outMessage.avatar_move.Direction = dirToMoveDir(movdir);
                        sendAMMessage(s, outMessage);

                        iterations++;
                        /* Avatar 0 counts iterations */
                        if (curAvatar == 0) {
				fprintf(stdout, "\033[2J\033[1;1H");
                                printf("iteration %d\n", iterations);
                                outstring = serializeWorldMap(*globalmap, nAvatars,
                                                inMessage.avatar_turn.Pos);
                                /* Print to stdout */
                                fprintf(stdout, "%s\n", outstring);
                                free(outstring);
                                if (algo == 2) {
                                        if (!(connectedToAll(*globalmap,
                                                                        pos[0], nAvatars))) {
                                                pknown = percentKnown(*globalmap, nAvatars);
                                        }
                                        fprintf(stdout, "percent known %.1f %%\n",
                                                        pknown*100);
                                }

                                for (i = 0; i < nAvatars; i++) {
                                        LOG(lmsg, fd_log, LVL_INFO,
                                                        "avatar %d (% 3d,% 3d) -> "
                                                        "(% 3d,% 3d)", i+1, (int)pos[i].x,
                                                        (int)pos[i].y,
                                                        (int)inMessage.avatar_turn.Pos[i].x,
                                                        (int)inMessage.avatar_turn.Pos[i].y);
                                }
                        }
                        /* Update our position */
                        for (i = 0; i < nAvatars; i++)
                                pos[i] = inMessage.avatar_turn.Pos[i];
                } else if (inMessage.avatar_turn.TurnId ==
                                (curAvatar + 1)%nAvatars && !firstMove) {
                        /* Update with results of previous move */
                        if (inMessage.type & AM_AVATAR_TURN)
                                updateWorldMap(globalmap, pos[curAvatar], movdir, inMessage,
                                                curAvatar, nAvatars, algo);
                        pthread_mutex_unlock(&globalmap->mapMutex);
                }
                firstMove = false;
        } while (!(inMessage.type & AM_MAZE_SOLVED) &&
                        !(inMessage.type == AM_TOO_MANY_MOVES));


        /* Detach and (if no other process is connected) deallocate shared memory */
        shmctl(shmid, IPC_RMID, NULL);
        close(s);

        if (curAvatar == 0) {
                if (inMessage.type & AM_MAZE_SOLVED) {
                        printf("Moves to solve: %" PRIu32, inMessage.maze_solved.nMoves);
                        printf("\n");
                        printf("Size = %dx%d\n", xlen, ylen);
                        printf("Algorithm = %d\n", algo);
                        printf("# of Avatars = %d\n", nAvatars);

                        /* print to log */
                        LOG(lmsg, fd_log, LVL_INFO, "Moves to Solve: %" PRIu32,
                                        inMessage.maze_solved.nMoves);
                        LOG(lmsg, fd_log, LVL_INFO, "Hash: %" PRIu32,
                                        inMessage.maze_solved.Hash);

                } else {
                        LOG(lmsg, fd_log, LVL_INFO, "Maze not solved after ~%d moves",
                                        iterations * nAvatars);
                        memset(&lmsg, 0, sizeof(lmsg));
                }
        }
        sleep(1);
        close(fd_log);
        unlink(FIFO_NAME);
        pthread_mutex_destroy(&globalmap->mapMutex);
        return 0;
}
开发者ID:seokjunbing,项目名称:MazeSolver,代码行数:101,代码来源:agent.c


示例8: pthread_mutex_destroy

 ~PosixMutex() {
   pthread_mutex_destroy(&mutex);
 }
开发者ID:damianob,项目名称:xcsoar,代码行数:3,代码来源:PosixMutex.hpp


示例9: main

int main (void) {

    int screen;			// which screen

    /* open connection with the server */
    display = XOpenDisplay(NULL);
    if(display == NULL) {
        fprintf(stderr, "cannot open display\n");
        return 0;
    }

    screen = DefaultScreen(display);

    /* set window position */
    int x = 0;
    int y = 0;

    /* border width in pixels */
    int border_width = 0;

    /* create window */
    window = XCreateSimpleWindow(display, RootWindow(display, screen), x, y,
        width, height, border_width,
            BlackPixel(display, screen), WhitePixel(display, screen));

    /* create graph */
    XGCValues values;
    long valuemask = 0;

    gc = XCreateGC(display, window, valuemask, &values);
    //XSetBackground (display, gc, WhitePixel (display, screen));
    XSetForeground (display, gc, BlackPixel (display, screen));
    XSetBackground(display, gc, 0X0000FF00);
    XSetLineAttributes (display, gc, 1, LineSolid, CapRound, JoinRound);

    /* map(show) the window */
    XMapWindow(display, window);
    XSync(display, 0);

    pthread_t threads[width];
    pthread_attr_t attr;

    /* 1. Initialize mutex variable objects. */
    pthread_mutex_init(&mutex, NULL);
    pthread_mutex_init(&ptr_mutex, NULL);

    /* For portability, explicitly create threads in a joinable state. */
    struct timespec t1, t2;
    clock_gettime(CLOCK_REALTIME, &t1);

    int i, j;
    long t;

    pthread_attr_init(&attr);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
    for (t=0; t<40; t++)
        pthread_create(&threads[t], &attr, draw_mandelbrot, (void *) t);

    /* Wait for all threads to complete. */
    for (i=0; i<40; i++)
        pthread_join(threads[i], NULL);

    /* Clean up and exit. */
    pthread_attr_destroy(&attr);
    pthread_mutex_destroy(&mutex);
    pthread_mutex_destroy(&ptr_mutex);

    /* end of record */
    clock_gettime(CLOCK_REALTIME, &t2);
    double timedif = 1000000*(t2.tv_sec-t1.tv_sec)+(t2.tv_nsec-t1.tv_nsec)/1000;
    printf("It took %.5lf seconds to finish dynamic pthread calculation.\n", timedif/1000000);
    printf("Going into sleep...\n");

    XFlush(display);
    sleep(3);
    return 0;
}
开发者ID:markakisdong,项目名称:parallel_programming,代码行数:77,代码来源:pthread_dynamic_mandelbrot.c


示例10: JNI_OnUnload

JNIEXPORT void JNI_OnUnload(JavaVM *jvm, void *reserved)
{
    ijkmp_global_uninit();

    pthread_mutex_destroy(&g_clazz.mutex);
}
开发者ID:126ium,项目名称:ijkplayer,代码行数:6,代码来源:ijkplayer_jni.c


示例11: sbmtx_free

void
sbmtx_free(sbmtx_t *mtx)
{
    pthread_mutex_destroy(&mtx->mtx);
    ckd_free(mtx);
}
开发者ID:zaqzaq,项目名称:cmusphinx,代码行数:6,代码来源:sbthread.c


示例12: pthread_mutex_destroy

Serial_Port::
~Serial_Port()
{
	// destroy mutex
	pthread_mutex_destroy(&lock);
}
开发者ID:Jerzy97,项目名称:Cardex,代码行数:6,代码来源:serial_port.cpp


示例13: dcethread_mutex_destroy

int
dcethread_mutex_destroy(dcethread_mutex *mutex)
{
    return dcethread__set_errno(pthread_mutex_destroy((pthread_mutex_t*) &mutex->mutex));
}
开发者ID:HumbleRepose,项目名称:dcerpc,代码行数:5,代码来源:dcethread_mutex_destroy.c


示例14: pthread_mutex_destroy

cMutex::~cMutex()
{
  pthread_mutex_destroy(&mutex);
  printf("mutex destroy returned %d:%s\n",errno,strerror(errno));
}
开发者ID:3PO,项目名称:vdr-plugin-sc,代码行数:5,代码来源:testMutex.c


示例15: pthread_mutex_destroy

/**
 * @brief OMX SwVdec queue destructor.
 */
omx_swvdec_queue::~omx_swvdec_queue()
{
    pthread_mutex_destroy(&m_mutex);
}
开发者ID:MIPS,项目名称:hardware-qcom-media,代码行数:7,代码来源:omx_swvdec_utils.cpp


示例16: __sync_sub_and_fetch

unsigned int One2OneChannel::unref()
{
    // atomic variable operation provided by gcc
    unsigned int ref = __sync_sub_and_fetch(&m_uiCount, 1);
    if (0 == ref)
    {
       this->finalize();
       delete this;
    }
    return ref;
}

void One2OneChannel::finalize()
{
    ec_rv_fatal( pthread_mutex_destroy(&m_sync) )
    ec_rv_fatal( pthread_cond_destroy(&m_cond) )
}

int One2OneChannel::init() {
    int rm = -1;
    int rc = -1;
   
    ec_rv( rm = pthread_mutex_init(&m_sync, NULL) )
    ec_rv( rc = pthread_cond_init(&m_cond, NULL) )

    // EC_LOG("success");
    return 0;

EC_CLEANUP_BGN
    if (0 == rm)
开发者ID:alex-ren,项目名称:cspats,代码行数:30,代码来源:cspats_lib.cpp


示例17: DestroyQueue

void DestroyQueue(Queue *Q) {
	destroyList(Q->front);
	sem_close(Q->sem);
	pthread_mutex_destroy(&(Q->mutex));
	free(Q);
}
开发者ID:pbmoura,项目名称:scalability_experiments,代码行数:6,代码来源:Queue.c


示例18: pthread_mutex_destroy

 TwoQStrategy::~TwoQStrategy() {
     pthread_mutex_destroy(&_preserved_mutex);
     pthread_mutex_destroy(&_fifo_mutex);
     pthread_mutex_destroy(&_lru_mutex);
     pthread_cond_destroy(&_preserved_changed);
 }
开发者ID:rummelj,项目名称:dbi,代码行数:6,代码来源:TwoQStrategy.cpp


示例19: BOOST_VERIFY

 ~mutex()
 {
     BOOST_VERIFY(!pthread_mutex_destroy(&m));
 }
开发者ID:xhy20070406,项目名称:PDAL,代码行数:4,代码来源:mutex.hpp


示例20: pthread_mutex_destroy

PThreadMutex::~PThreadMutex()

{
    pthread_mutex_destroy( hMutex );
    free( hMutex );
}
开发者ID:0004c,项目名称:node-gdal,代码行数:6,代码来源:pthread_mutex.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ pthread_mutex_timedlock函数代码示例发布时间:2022-05-30
下一篇:
C++ pthread_mach_thread_np函数代码示例发布时间: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