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


C++ slock_unlock函数代码示例

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


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

示例1: android_app_set_input

static void android_app_set_input(void *data, AInputQueue* inputQueue)
{
   struct android_app *android_app = (struct android_app*)data;

   if (!android_app)
      return;

   slock_lock(android_app->mutex);
   android_app->pendingInputQueue = inputQueue;
   android_app_write_cmd(android_app, APP_CMD_INPUT_CHANGED);
   while (android_app->inputQueue != android_app->pendingInputQueue)
      scond_wait(android_app->cond, android_app->mutex);
   slock_unlock(android_app->mutex);
}
开发者ID:ipoly,项目名称:RetroArch,代码行数:14,代码来源:platform_android.c

示例2: ffemu_push_audio

bool ffemu_push_audio(ffemu_t *handle, const struct ffemu_audio_data *data)
{
   if (!handle->config.audio_enable)
      return true;

   for (;;)
   {
      slock_lock(handle->lock);
      unsigned avail = fifo_write_avail(handle->audio_fifo);
      slock_unlock(handle->lock);

      if (!handle->alive)
         return false;

      if (avail >= data->frames * handle->params.channels * sizeof(int16_t))
         break;

      slock_lock(handle->cond_lock);
      if (handle->can_sleep)
      {
         handle->can_sleep = false;
         scond_wait(handle->cond, handle->cond_lock);
         handle->can_sleep = true;
      }
      else
         scond_signal(handle->cond);

      slock_unlock(handle->cond_lock);
   }

   slock_lock(handle->lock);
   fifo_write(handle->audio_fifo, data->data, data->frames * handle->params.channels * sizeof(int16_t));
   slock_unlock(handle->lock);
   scond_signal(handle->cond);

   return true;
}
开发者ID:saulocastelo,项目名称:RetroArch,代码行数:37,代码来源:ffemu.c

示例3: sl_write

static ssize_t sl_write(void *data, const void *buf_, size_t size)
{
   sl_t *sl = (sl_t*)data;

   size_t written = 0;
   const uint8_t *buf = (const uint8_t*)buf_;

   while (size)
   {
      if (sl->nonblock)
      {
         if (sl->buffered_blocks == sl->buf_count)
            break;
      }
      else
      {
         slock_lock(sl->lock);
         while (sl->buffered_blocks == sl->buf_count)
            scond_wait(sl->cond, sl->lock);
         slock_unlock(sl->lock);
      }

      size_t avail_write = min(sl->buf_size - sl->buffer_ptr, size);
      if (avail_write)
      {
         memcpy(sl->buffer[sl->buffer_index] + sl->buffer_ptr, buf, avail_write);
         sl->buffer_ptr += avail_write;
         buf            += avail_write;
         size           -= avail_write;
         written        += avail_write;
      }

      if (sl->buffer_ptr >= sl->buf_size)
      {
         SLresult res = (*sl->buffer_queue)->Enqueue(sl->buffer_queue, sl->buffer[sl->buffer_index], sl->buf_size);
         sl->buffer_index = (sl->buffer_index + 1) % sl->buf_count;
         __sync_fetch_and_add(&sl->buffered_blocks, 1);
         sl->buffer_ptr = 0;

         if (res != SL_RESULT_SUCCESS)
         {
            RARCH_ERR("[OpenSL]: Failed to write! (Error: 0x%x)\n", (unsigned)res);
            return -1;
         }
      }
   }

   return written;
}
开发者ID:mprobinson,项目名称:RetroArch,代码行数:49,代码来源:opensl.c

示例4: autosave_free

void autosave_free(autosave_t *handle)
{
   slock_lock(handle->cond_lock);
   handle->quit = true;
   slock_unlock(handle->cond_lock);
   scond_signal(handle->cond);
   sthread_join(handle->thread);

   slock_free(handle->lock);
   slock_free(handle->cond_lock);
   scond_free(handle->cond);

   free(handle->buffer);
   free(handle);
}
开发者ID:Wyrick,项目名称:RetroArch,代码行数:15,代码来源:autosave.c

示例5: thread_set_viewport

static void thread_set_viewport(void *data, unsigned width,
      unsigned height, bool force_full, bool allow_rotate)
{
   thread_video_t *thr = (thread_video_t*)data;
   if (!thr)
      return;
    
   slock_lock(thr->lock);

    if (thr->driver && thr->driver->set_viewport)
        thr->driver->set_viewport(thr->driver_data, width, height,
                                  force_full, allow_rotate);
    
   slock_unlock(thr->lock);
}
开发者ID:netux79,项目名称:RAvideoFixes,代码行数:15,代码来源:video_thread_wrapper.c

示例6: rarch_softfilter_process

void rarch_softfilter_process(rarch_softfilter_t *filt,
      void *output, size_t output_stride,
      const void *input, unsigned width, unsigned height, size_t input_stride)
{
   unsigned i;

   if (filt && filt->impl && filt->impl->get_work_packets)
      filt->impl->get_work_packets(filt->impl_data, filt->packets,
            output, output_stride, input, width, height, input_stride);
   
#ifdef HAVE_THREADS
   // Fire off workers
   for (i = 0; i < filt->threads; i++)
   {
      //RARCH_LOG("Firing off filter thread %u ...\n", i);
      filt->thread_data[i].packet = &filt->packets[i];
      slock_lock(filt->thread_data[i].lock);
      filt->thread_data[i].done = false;
      scond_signal(filt->thread_data[i].cond);
      slock_unlock(filt->thread_data[i].lock);
   }

   // Wait for workers
   for (i = 0; i < filt->threads; i++)
   {
      //RARCH_LOG("Waiting for filter thread %u ...\n", i);
      slock_lock(filt->thread_data[i].lock);
      while (!filt->thread_data[i].done)
         scond_wait(filt->thread_data[i].cond, filt->thread_data[i].lock);
      slock_unlock(filt->thread_data[i].lock);
   }
#else
   for (i = 0; i < filt->threads; i++)
      filt->packets[i].work(filt->impl_data, filt->packets[i].thread_data);
#endif
}
开发者ID:Mbcpro,项目名称:RetroArch,代码行数:36,代码来源:filter.c

示例7: filter_thread_loop

static void filter_thread_loop(void *data)
{
   struct filter_thread_data *thr = (struct filter_thread_data*)data;

   for (;;)
   {
      slock_lock(thr->lock);
      while (thr->done && !thr->die)
         scond_wait(thr->cond, thr->lock);
      bool die = thr->die;
      slock_unlock(thr->lock);

      if (die)
         break;

      if (thr->packet && thr->packet->work)
         thr->packet->work(thr->userdata, thr->packet->thread_data);

      slock_lock(thr->lock);
      thr->done = true;
      scond_signal(thr->cond);
      slock_unlock(thr->lock);
   }
}
开发者ID:Mbcpro,项目名称:RetroArch,代码行数:24,代码来源:filter.c

示例8: DequeueRender

TA_context* DequeueRender(void)
{
#ifndef TARGET_NO_THREADS
   slock_lock(mtx_rqueue);
#endif
	TA_context* rv = rqueue;
#ifndef TARGET_NO_THREADS
   slock_unlock(mtx_rqueue);
#endif

	if (rv)
		FrameCount++;

	return rv;
}
开发者ID:Kivutar,项目名称:reicast-emulator,代码行数:15,代码来源:ta_ctx.cpp

示例9: android_app_set_activity_state

static void android_app_set_activity_state (void *data, int8_t cmd)
{
   struct android_app *android_app = (struct android_app*)data;

   if (!android_app)
      return;

   slock_lock(android_app->mutex);
   android_app_write_cmd(android_app, cmd);
   while (android_app->activityState != cmd && android_app->activityState != APP_CMD_DEAD)
      scond_wait(android_app->cond, android_app->mutex);
   slock_unlock(android_app->mutex);

   if (android_app->activityState == APP_CMD_DEAD)
      RARCH_LOG("RetroArch native thread is dead.\n");
}
开发者ID:joshuamelia,项目名称:RetroArch,代码行数:16,代码来源:platform_android.c

示例10: ssem_signal

void ssem_signal(ssem_t *semaphore)
{
   if (!semaphore)
      return;

   slock_lock(semaphore->mutex);
   semaphore->value++;

   if (semaphore->value <= 0)
   {
      semaphore->wakeups++;
      scond_signal(semaphore->cond);
   }

   slock_unlock(semaphore->mutex);
}
开发者ID:Kivutar,项目名称:RetroArch,代码行数:16,代码来源:rsemaphore.c

示例11: data_runloop_thread_deinit

static void data_runloop_thread_deinit(data_runloop_t *runloop)
{
   if (!runloop->thread_inited)
   {
      slock_lock(runloop->cond_lock);
      runloop->alive = false;
      scond_signal(runloop->cond);
      slock_unlock(runloop->cond_lock);
      sthread_join(runloop->thread);

      slock_free(runloop->lock);
      slock_free(runloop->cond_lock);
      rarch_main_data_overlay_thread_uninit();
      scond_free(runloop->cond);
   }
}
开发者ID:rglass01,项目名称:RetroArch,代码行数:16,代码来源:runloop_data.c

示例12: slock_lock

const char *rarch_main_msg_queue_pull(void)
{
   const char *ret = NULL;

#ifdef HAVE_THREADS
   slock_lock(mq_lock);
#endif

   ret = msg_queue_pull(g_msg_queue);

#ifdef HAVE_THREADS
   slock_unlock(mq_lock);
#endif

   return ret;
}
开发者ID:ioev,项目名称:RetroArch,代码行数:16,代码来源:runloop_msg.c

示例13: data_runloop_thread_deinit

static void data_runloop_thread_deinit(void)
{
   if (!g_data_runloop.thread_inited)
   {
      slock_lock(g_data_runloop.cond_lock);
      g_data_runloop.alive = false;
      scond_signal(g_data_runloop.cond);
      slock_unlock(g_data_runloop.cond_lock);
      sthread_join(g_data_runloop.thread);

      slock_free(g_data_runloop.lock);
      slock_free(g_data_runloop.cond_lock);
      rarch_main_data_overlay_thread_uninit();
      scond_free(g_data_runloop.cond);
   }
}
开发者ID:brianblakely,项目名称:RetroArch,代码行数:16,代码来源:runloop_data.c

示例14: thread_alive

static bool thread_alive(void *data)
{
   thread_video_t *thr = (thread_video_t*)data;
   if (g_extern.is_paused)
   {
      thread_send_cmd(thr, CMD_ALIVE);
      thread_wait_reply(thr, CMD_ALIVE);
      return thr->cmd_data.b;
   }
   else
   {
      slock_lock(thr->lock);
      bool ret = thr->alive;
      slock_unlock(thr->lock);
      return ret;
   }
}
开发者ID:chiefdeputy,项目名称:RetroArch,代码行数:17,代码来源:video_thread_wrapper.c

示例15: retro_task_threaded_cancel

static void retro_task_threaded_cancel(void *task)
{
   retro_task_t *t;

   slock_lock(running_lock);

   for (t = tasks_running.front; t; t = t->next)
   {
      if (t == task)
      {
        t->cancelled = true;
        break;
      }
   }

   slock_unlock(running_lock);
}
开发者ID:Ezio-PS,项目名称:RetroArch,代码行数:17,代码来源:task_queue.c


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