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


C++ slock_new函数代码示例

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


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

示例1: rarch_main_data_thread_init

static void rarch_main_data_thread_init(void)
{
   data_runloop_t *runloop  = rarch_main_data_get_ptr();

   if (!runloop)
      return;

   runloop->lock            = slock_new();
   runloop->cond_lock       = slock_new();
   runloop->cond            = scond_new();

#ifdef HAVE_OVERLAY
   rarch_main_data_overlay_thread_init();
#endif

   runloop->thread    = sthread_create(data_thread_loop, runloop);

   if (!runloop->thread)
      goto error;

   slock_lock(runloop->lock);
   runloop->thread_inited   = true;
   runloop->alive           = true;
   runloop->thread_code     = THREAD_CODE_ALIVE;
   slock_unlock(runloop->lock);

   return;

error:
   data_runloop_thread_deinit(runloop);
}
开发者ID:aldatsa,项目名称:RetroArch,代码行数:31,代码来源:runloop_data.c

示例2: thread_init

static bool thread_init(thread_video_t *thr, const video_info_t *info, const input_driver_t **input,
                        void **input_data)
{
    thr->lock = slock_new();
    thr->frame.lock = slock_new();
    thr->cond_cmd = scond_new();
    thr->cond_thread = scond_new();
    thr->input = input;
    thr->input_data = input_data;
    thr->info = *info;
    thr->alive = true;
    thr->focus = true;

    size_t max_size = info->input_scale * RARCH_SCALE_BASE;
    max_size *= max_size;
    max_size *= info->rgb32 ? sizeof(uint32_t) : sizeof(uint16_t);
    thr->frame.buffer = (uint8_t*)malloc(max_size);
    if (!thr->frame.buffer)
        return false;

    memset(thr->frame.buffer, 0x80, max_size);

    thr->target_frame_time = (rarch_time_t)roundf(1000000LL / g_settings.video.refresh_rate);
    thr->last_time = rarch_get_time_usec();

    thr->thread = sthread_create(thread_loop, thr);
    if (!thr->thread)
        return false;
    thread_send_cmd(thr, CMD_INIT);
    thread_wait_reply(thr, CMD_INIT);

    return thr->cmd_data.b;
}
开发者ID:CatalystG,项目名称:RetroArch,代码行数:33,代码来源:thread_wrapper.c

示例3: rarch_main_data_thread_init

static void rarch_main_data_thread_init(void)
{
   g_data_runloop.lock            = slock_new();
   g_data_runloop.cond_lock       = slock_new();
   g_data_runloop.cond            = scond_new();

#ifdef HAVE_OVERLAY
   rarch_main_data_overlay_thread_init();
#endif

   g_data_runloop.thread    = sthread_create(data_thread_loop, &g_data_runloop);

   if (!g_data_runloop.thread)
      goto error;

   slock_lock(g_data_runloop.lock);
   g_data_runloop.thread_inited   = true;
   g_data_runloop.alive           = true;
   g_data_runloop.thread_code     = THREAD_CODE_ALIVE;
   slock_unlock(g_data_runloop.lock);

   return;

error:
   data_runloop_thread_deinit();
}
开发者ID:brianblakely,项目名称:RetroArch,代码行数:26,代码来源:runloop_data.c

示例4: sizeof

autosave_t *autosave_new(const char *path, const void *data, size_t size, unsigned interval)
{
    autosave_t *handle = (autosave_t*)calloc(1, sizeof(*handle));
    if (!handle)
        return NULL;

    handle->bufsize = size;
    handle->interval = interval;
    handle->path = path;
    handle->buffer = malloc(size);
    handle->snes_buffer = data;

    if (!handle->buffer)
    {
        free(handle);
        return NULL;
    }
    memcpy(handle->buffer, handle->snes_buffer, handle->bufsize);

    handle->lock = slock_new();
    handle->cond_lock = slock_new();
    handle->cond = scond_new();

    handle->thread = sthread_create(autosave_thread, handle);

    return handle;
}
开发者ID:magicseb,项目名称:RetroArch,代码行数:27,代码来源:autosave.c

示例5: retro_task_threaded_init

static void retro_task_threaded_init(void)
{
   running_lock  = slock_new();
   finished_lock = slock_new();
   worker_cond   = scond_new();

   slock_lock(running_lock);
   worker_continue = true;
   slock_unlock(running_lock);

   worker_thread = sthread_create(threaded_worker, NULL);
}
开发者ID:Ezio-PS,项目名称:RetroArch,代码行数:12,代码来源:task_queue.c

示例6: dispmanx_surface_setup

static void dispmanx_surface_setup(void *data, int width, int height, int pitch, float aspect,
   struct dispmanx_surface *surface)
{
   struct dispmanx_video *_dispvars = data;
   int i, dst_width, dst_height, dst_xpos, dst_ypos;

   /* Allocate memory for all the pages in each surface
    * and initialize variables inside each page's struct. */
   surface->pages = calloc(surface->numpages, sizeof(struct dispmanx_page));
   for (i = 0; i < surface->numpages; i++) {
      surface->pages[i].used = false;   
      surface->pages[i].dispvars = _dispvars;   
      surface->pages[i].page_used_mutex = slock_new(); 
   }

   /* Internal frame dimensions. Pitch is total pitch including info 
    * between scanlines */
   surface->width = width;
   surface->height = height;
   surface->pitch = pitch;
   surface->aspect = aspect;  
 
   /* The "visible" width obtained from the core pitch. We blit based on 
    * the "visible" width, for cores with things between scanlines. */
   int visible_width = pitch / surface->bpp;
 
   dst_width  = _dispvars->dispmanx_height * aspect;	
   dst_height = _dispvars->dispmanx_height;
   
   /* If we obtain a scaled image width that is bigger than the physical screen width,
   * then we keep the physical screen width as our maximun width. */
   if (dst_width > _dispvars->dispmanx_width) 
      dst_width = _dispvars->dispmanx_width;
   
   dst_xpos = (_dispvars->dispmanx_width - dst_width) / 2;
   dst_ypos = (_dispvars->dispmanx_height - dst_height) / 2;

   /* We configure the rects now. */
   vc_dispmanx_rect_set(&surface->dst_rect, dst_xpos, dst_ypos, dst_width, dst_height);
   vc_dispmanx_rect_set(&surface->bmp_rect, 0, 0, width, height);	
   vc_dispmanx_rect_set(&surface->src_rect, 0, 0, width << 16, height << 16);	

   for (i = 0; i < surface->numpages; i++) {
      surface->pages[i].resource = 
         vc_dispmanx_resource_create(surface->pixformat, 
	 visible_width, height, &(_dispvars->vc_image_ptr));
   }
   /* Add element. */
   _dispvars->update = vc_dispmanx_update_start(0);

   surface->element = vc_dispmanx_element_add(
      _dispvars->update,_dispvars->display, surface->layer, 
      &surface->dst_rect, surface->pages[0].resource, 
      &surface->src_rect, DISPMANX_PROTECTION_NONE,
      &surface->alpha, 0, (DISPMANX_TRANSFORM_T)0);

   vc_dispmanx_update_submit_sync(_dispvars->update);		

   surface->setup = true;
}
开发者ID:luiseduardohdbackup,项目名称:RetroArch,代码行数:60,代码来源:dispmanx_gfx.c

示例7: sizeof

async_job_t *async_job_new(void)
{
   async_job_t *ajob = (async_job_t*)calloc(1, sizeof(*ajob));
   
   if (!ajob)
      return NULL;

   ajob->lock   = slock_new();

   if (!ajob->lock)
      goto error;

   ajob->sem = ssem_new(0);

   if (!ajob->sem)
      goto error;

   ajob->thread = sthread_create(async_job_processor, (void*)ajob);

   if (!ajob->thread)
      goto error;

   return ajob;

error:
   if (ajob->lock)
      slock_free(ajob->lock);
   ajob->lock = NULL;
   if (ajob->sem)
      ssem_free(ajob->sem);
   if (ajob)
      free((void*)ajob);
   return NULL;
}
开发者ID:Kivutar,项目名称:RetroArch,代码行数:34,代码来源:async_job.c

示例8: sizeof

ssem_t *ssem_new(int value)
{
   ssem_t *semaphore = (ssem_t*)calloc(1, sizeof(*semaphore));

   if (!semaphore)
      goto error;
   
   semaphore->value   = value;
   semaphore->wakeups = 0;
   semaphore->mutex   = slock_new();

   if (!semaphore->mutex)
      goto error;

   semaphore->cond = scond_new();

   if (!semaphore->cond)
      goto error;

   return semaphore;

error:
   if (semaphore->mutex)
      slock_free(semaphore->mutex);
   semaphore->mutex = NULL;
   if (semaphore)
      free((void*)semaphore);
   return NULL;
}
开发者ID:Kivutar,项目名称:RetroArch,代码行数:29,代码来源:rsemaphore.c

示例9: calloc

static void *drm_gfx_init(const video_info_t *video,
      const input_driver_t **input, void **input_data)
{
   struct drm_video *_drmvars = (struct drm_video*)
      calloc(1, sizeof(struct drm_video));
   if (!_drmvars)
      return NULL;

   /* Setup surface parameters */
   _drmvars->menu_active      = false;
   _drmvars->rgb32            = video->rgb32; 

   /* It's very important that we set aspect here because the 
    * call seq when a core is loaded is gfx_init()->set_aspect()->gfx_frame()
    * and we don't want the main surface to be setup in set_aspect() 
    * before we get to gfx_frame(). */
   _drmvars->current_aspect = video_driver_get_aspect_ratio();

   /* Initialize the rest of the mutexes and conditions. */
   _drmvars->vsync_condition  = scond_new();
   _drmvars->vsync_cond_mutex = slock_new();
   _drmvars->pending_mutex    = slock_new();
   _drmvars->core_width       = 0;
   _drmvars->core_height      = 0;

   _drmvars->main_surface     = NULL;
   _drmvars->menu_surface     = NULL;

   if (input && input_data)
      *input = NULL;

   /* DRM Init */
   if (!init_drm())
   {
      RARCH_ERR ("DRM: Failed to initialize DRM\n");
      return NULL;
   }
   else
      RARCH_LOG ("DRM: Init succesful.\n");

   _drmvars->kms_width  = drm.current_mode->hdisplay;  
   _drmvars->kms_height = drm.current_mode->vdisplay;  
 
   return _drmvars;
}
开发者ID:IlDucci,项目名称:RetroArch,代码行数:45,代码来源:drm_gfx.c

示例10: drm_surface_setup

static void drm_surface_setup(void *data,  int src_width, int src_height, 
      int pitch, int bpp, uint32_t pixformat,
      int alpha, float aspect, int numpages, int layer, 
      struct drm_surface **sp)
{
   struct drm_video *_drmvars = data;
   int i;
   struct drm_surface *surface = NULL;

   *sp = calloc (1, sizeof(struct drm_surface));

   surface = *sp;   

   /* Setup surface parameters */
   surface->numpages = numpages;
   /* We receive the total pitch, including things that are 
    * between scanlines and we calculate the visible pitch 
    * from the visible width. 
    *
    * These will be used to increase the offsets for blitting. */
   surface->total_pitch = pitch;
   surface->pitch       = src_width * bpp; 
   surface->bpp         = bpp;
   surface->pixformat   = pixformat;
   surface->src_width   = src_width;
   surface->src_height  = src_height;
   surface->aspect      = aspect;
   
   /* Allocate memory for all the pages in each surface
    * and initialize variables inside each page's struct. */
   surface->pages = (struct drm_page*)
      calloc(surface->numpages, sizeof(struct drm_page));

   for (i = 0; i < surface->numpages; i++)
   {
      surface->pages[i].used            = false;   
      surface->pages[i].surface         = surface;   
      surface->pages[i].drmvars         = _drmvars;   
      surface->pages[i].page_used_mutex = slock_new(); 
   }

   /* Create the framebuffer for each one of the pages of the surface. */
   for (i = 0; i < surface->numpages; i++)
   {
      surface->pages[i].buf.width  = src_width;
      surface->pages[i].buf.height = src_height;
      int ret                      = modeset_create_dumbfb(
            drm.fd, &surface->pages[i].buf, bpp, pixformat);	

      if (ret)
      {
         RARCH_ERR ("DRM: can't create fb\n");
      }
   }

   surface->flip_page = 0;
}
开发者ID:IlDucci,项目名称:RetroArch,代码行数:57,代码来源:drm_gfx.c

示例11: calloc

static void *sunxi_gfx_init(const video_info_t *video,
      const input_driver_t **input, void **input_data)
{
   struct sunxi_video *_dispvars = (struct sunxi_video*)
      calloc(1, sizeof(struct sunxi_video));

   if (!_dispvars)
      return NULL;

   _dispvars->src_bytes_per_pixel = video->rgb32 ? 4 : 2;
   _dispvars->sunxi_disp          = sunxi_disp_init("/dev/fb0");

   /* Blank text console and disable cursor blinking. */
   sunxi_blank_console(_dispvars);

   _dispvars->pages = (struct sunxi_page*)calloc(NUMPAGES, sizeof (struct sunxi_page));

   if (!_dispvars->pages)
      goto error;

   _dispvars->dst_pitch           = _dispvars->sunxi_disp->xres * _dispvars->sunxi_disp->bits_per_pixel / 8;
   /* Considering 4 bytes per pixel since we will be in 32bpp on the CB/CB2/CT for hw scalers to work. */
   _dispvars->dst_pixels_per_line = _dispvars->dst_pitch / 4;
   _dispvars->pageflip_pending    = false;
   _dispvars->nextPage            = &_dispvars->pages[0];
   _dispvars->keep_vsync          = true;
   _dispvars->menu_active         = false;
   _dispvars->bytes_per_pixel     = video->rgb32 ? 4 : 2;

   switch (_dispvars->bytes_per_pixel)
   {
      case 2:
         pixman_blit = pixman_composite_src_0565_8888_asm_neon;
         break;
      case 4:
         pixman_blit = pixman_composite_src_8888_8888_asm_neon;
         break;
      default:
         goto error;
   }

   _dispvars->pending_mutex    = slock_new();
   _dispvars->vsync_condition  = scond_new();

   if (input && input_data)
      *input = NULL;

   /* Launching vsync thread */
   _dispvars->vsync_thread     = sthread_create(sunxi_vsync_thread_func, _dispvars);

   return _dispvars;

error:
   if (_dispvars)
      free(_dispvars);
   return NULL;
}
开发者ID:luiseduardohdbackup,项目名称:RetroArch,代码行数:57,代码来源:sunxi_gfx.c

示例12: calloc

static void *dispmanx_gfx_init(const video_info_t *video,
      const input_driver_t **input, void **input_data)
{
	int i; 
	struct dispmanx_video *_dispvars = calloc(1, sizeof(struct dispmanx_video));

   if (!_dispvars)
      return NULL;

	_dispvars->bytes_per_pixel  = video->rgb32 ? 4 : 2;
	_dispvars->screen           = 0;
	_dispvars->vcImagePtr       = 0;
	_dispvars->pageflip_pending = 0;	
	_dispvars->currentPage      = NULL;
	_dispvars->pages            = calloc(NUMPAGES, sizeof(struct dispmanx_page));

   if (!_dispvars->pages)
   {
      free(_dispvars);
      return NULL;
   }

	for (i = 0; i < NUMPAGES; i++)
   {
		_dispvars->pages[i].numpage         = i;
		_dispvars->pages[i].used            = false;
		_dispvars->pages[i].dispvars        = _dispvars;
		_dispvars->pages[i].page_used_mutex = slock_new(); 
	}

	/* Initialize the rest of the mutexes and conditions. */
	_dispvars->vsync_condition  = scond_new();
	_dispvars->pending_mutex    = slock_new();
	_dispvars->vsync_cond_mutex = slock_new(); 

	bcm_host_init();

	_dispvars->display = vc_dispmanx_display_open(_dispvars->screen);

	if (input && input_data)
		*input = NULL;

	return _dispvars;
}
开发者ID:CautiousAlbino,项目名称:RetroArch,代码行数:44,代码来源:dispmanx_gfx.c

示例13: thread_init

static bool thread_init(thread_video_t *thr, const video_info_t *info,
      const input_driver_t **input, void **input_data)
{
   size_t max_size;
   thread_packet_t pkt = {CMD_INIT};

   thr->lock                 = slock_new();
   thr->alpha_lock           = slock_new();
   thr->frame.lock           = slock_new();
   thr->cond_cmd             = scond_new();
   thr->cond_thread          = scond_new();
   thr->input                = input;
   thr->input_data           = input_data;
   thr->info                 = *info;
   thr->alive                = true;
   thr->focus                = true;
   thr->has_windowed         = true;
   thr->suppress_screensaver = true;

   max_size                  = info->input_scale * RARCH_SCALE_BASE;
   max_size                 *= max_size;
   max_size                 *= info->rgb32 ? sizeof(uint32_t) : sizeof(uint16_t);
   thr->frame.buffer        = (uint8_t*)malloc(max_size);

   if (!thr->frame.buffer)
      return false;

   memset(thr->frame.buffer, 0x80, max_size);

   thr->last_time       = rarch_get_time_usec();
   thr->thread          = sthread_create(thread_loop, thr);
   if (!thr->thread)
      return false;

   thread_send_and_wait(thr, &pkt);

/*   thr->send_cmd_func   = thread_send_cmd;   */
/*   thr->wait_reply_func = thread_wait_reply; */

   thr->send_and_wait = thread_send_and_wait;
   return pkt.data.b;
}
开发者ID:netux79,项目名称:RAvideoFixes,代码行数:42,代码来源:video_thread_wrapper.c

示例14: slock_new

Task::Impl::Impl()
{
	_isThreadRunning = false;
	workFunc = NULL;
	workFuncParam = NULL;
	ret = NULL;
	exitThread = false;

	mutex = slock_new();
   condWork = scond_new();
}
开发者ID:lcsaintlee,项目名称:desmume-1,代码行数:11,代码来源:task.cpp

示例15: init_thread

static bool init_thread(ffemu_t *handle)
{
   handle->lock = slock_new();
   handle->cond_lock = slock_new();
   handle->cond = scond_new();
   handle->audio_fifo = fifo_new(32000 * sizeof(int16_t) * handle->params.channels * MAX_FRAMES / 60);
   handle->attr_fifo = fifo_new(sizeof(struct ffemu_video_data) * MAX_FRAMES);
   handle->video_fifo = fifo_new(handle->params.fb_width * handle->params.fb_height *
            handle->video.pix_size * MAX_FRAMES);

   handle->alive = true;
   handle->can_sleep = true;
   handle->thread = sthread_create(ffemu_thread, handle);

   assert(handle->lock && handle->cond_lock &&
      handle->cond && handle->audio_fifo &&
      handle->attr_fifo && handle->video_fifo && handle->thread);

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


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