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

C++ slock_unlock函数代码示例

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

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



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


示例16: rs_write

static ssize_t rs_write(void *data, const void *buf, size_t size)
{
   rsd_t *rsd = (rsd_t*)data;

   if (rsd->has_error)
      return -1;

   if (rsd->nonblock)
   {
      rsd_callback_lock(rsd->rd);
      size_t avail = fifo_write_avail(rsd->buffer);
      size_t write_amt = avail > size ? size : avail;
      fifo_write(rsd->buffer, buf, write_amt);
      rsd_callback_unlock(rsd->rd);
      return write_amt;
   }
   else
   {
      size_t written = 0;
      while (written < size && !rsd->has_error)
      {
         rsd_callback_lock(rsd->rd);
         size_t avail = fifo_write_avail(rsd->buffer);

         if (avail == 0)
         {
            rsd_callback_unlock(rsd->rd);
            if (!rsd->has_error)
            {
               slock_lock(rsd->cond_lock);
               scond_wait(rsd->cond, rsd->cond_lock);
               slock_unlock(rsd->cond_lock);
            }
         }
         else
         {
            size_t write_amt = size - written > avail ? avail : size - written;
            fifo_write(rsd->buffer, (const char*)buf + written, write_amt);
            rsd_callback_unlock(rsd->rd);
            written += write_amt;
         }
      }
      return written;
   }
}
开发者ID:Jalle19,项目名称:RetroArch,代码行数:45,代码来源:rsound.c


示例17: adapter_thread

static void adapter_thread(void *data)
{
   uint8_t __attribute__((aligned(32))) send_command_buf[4096];
   struct wiiusb_adapter *adapter = (struct wiiusb_adapter*)data;
   wiiusb_hid_t *hid = adapter ? adapter->hid : NULL;

   if (!adapter)
      return;

   while (!adapter->quitting)
   {
      size_t send_command_size;
      int tmp;
      int report_number;
      int size = 0;

      (void)tmp;
      (void)report_number;

      slock_lock(adapter->send_control_lock);

      if (fifo_read_avail(adapter->send_control_buffer) >= sizeof(send_command_size))
      {
         fifo_read(adapter->send_control_buffer, &send_command_size, sizeof(send_command_size));
         if (fifo_read_avail(adapter->send_control_buffer) >= sizeof(send_command_size))
         {
            fifo_read(adapter->send_control_buffer, send_command_buf, send_command_size);
            USB_WriteIntrMsg(adapter->handle, adapter->endpoint_out, send_command_size, send_command_buf);
         }
      }
      slock_unlock(adapter->send_control_lock);

      size = USB_ReadIntrMsg(adapter->handle, adapter->endpoint_in, adapter->endpoint_in_max_size, &adapter->data[0]);
      /* RARCH_LOG("%p USB_ReadIntrMsg(%i, %i, %i, %p): %i\n", &adapter->data[0],
         adapter->handle, adapter->endpoint_in, adapter->endpoint_in_max_size, &adapter->data[0],
         size); */

      //RARCH_LOG("%03i %03i %03i %03i\n", adapter->data[0], adapter->data[1], adapter->data[2], adapter->data[3], adapter->data[4]);
      //memmove(&adapter->data[1], &adapter->data[0], 2048);

      if (adapter && hid && hid->slots && size)
         pad_connection_packet(&hid->slots[adapter->slot], adapter->slot,
               adapter->data - 1, size+1);
   }
}
开发者ID:jimmy906,项目名称:RetroArch,代码行数:45,代码来源:wiiusb_hid.c


示例18: retro_task_threaded_deinit

static void retro_task_threaded_deinit(void)
{
   slock_lock(running_lock);
   worker_continue = false;
   scond_signal(worker_cond);
   slock_unlock(running_lock);

   sthread_join(worker_thread);

   scond_free(worker_cond);
   slock_free(running_lock);
   slock_free(finished_lock);

   worker_thread = NULL;
   worker_cond   = NULL;
   running_lock  = NULL;
   finished_lock = NULL;
}
开发者ID:Ezio-PS,项目名称:RetroArch,代码行数:18,代码来源:task_queue.c


示例19: rarch_main_msg_queue_free

void rarch_main_msg_queue_free(void)
{
   if (!g_msg_queue)
      return;

#ifdef HAVE_THREADS
   slock_lock(mq_lock);
#endif

   msg_queue_free(g_msg_queue);

#ifdef HAVE_THREADS
   slock_unlock(mq_lock);
   slock_free(mq_lock);
#endif

   g_msg_queue = NULL;
}
开发者ID:ioev,项目名称:RetroArch,代码行数:18,代码来源:runloop_msg.c


示例20: thread_alive

static bool thread_alive(void *data)
{
   bool ret;
   thread_video_t *thr = (thread_video_t*)data;

   if (rarch_main_is_paused())
   {
      thread_packet_t pkt = { CMD_ALIVE };
      thread_send_and_wait(thr, &pkt);
      return pkt.data.b;
   }

   slock_lock(thr->lock);
   ret = thr->alive;
   slock_unlock(thr->lock);

   return ret;
}
开发者ID:HahPagan,项目名称:RetroArch,代码行数:18,代码来源:video_thread_wrapper.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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