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


C++ caml_enter_blocking_section函数代码示例

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


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

示例1: exec_not_null_callback

static inline int exec_not_null_callback(
  void *cbx_, int num_columns, char **row, char **header)
{
  callback_with_exn *cbx = cbx_;
  value v_row, v_header, v_ret;

  caml_leave_blocking_section();

    v_row = copy_not_null_string_array((const char **) row, num_columns);

    if (v_row == (value) NULL) return 1;

    Begin_roots1(v_row);
      v_header = safe_copy_string_array((const char **) header, num_columns);
    End_roots();

    v_ret = caml_callback2_exn(*cbx->cbp, v_row, v_header);

    if (Is_exception_result(v_ret)) {
      *cbx->exn = Extract_exception(v_ret);
      caml_enter_blocking_section();
      return 1;
    }

  caml_enter_blocking_section();

  return 0;
}
开发者ID:Moondee,项目名称:caut-lib,代码行数:28,代码来源:sqlite3_stubs.c

示例2: caml_md5_fd

/* Contrary to caml_md5_chan, this function releases the runtime lock.

   [fd] must be a file descriptor open for reading and not be
   nonblocking, otherwise the function might fail non-deterministically.
 */
CAMLprim value caml_md5_fd(value fd)
{
  CAMLparam1 (fd);
  value res;
  struct MD5Context ctx;
  caml_enter_blocking_section();
  {
    intnat bytes_read;
    char buffer[4096];

    caml_MD5Init(&ctx);
    while (1){
      bytes_read = read (Int_val(fd), buffer, sizeof(buffer));
      if (bytes_read < 0) {
        if (errno == EINTR) continue;
        caml_leave_blocking_section();
        uerror("caml_md5_fd", Nothing);
      }
      if (bytes_read == 0) break;
      caml_MD5Update (&ctx, (unsigned char *) buffer, bytes_read);
    }
  }
  caml_leave_blocking_section();
  res = caml_alloc_string(16);
  caml_MD5Final(&Byte_u(res, 0), &ctx);
  CAMLreturn (res);
}
开发者ID:janestreet,项目名称:jenga,代码行数:32,代码来源:digest_stubs.c

示例3: ffmpeg_close

value
ffmpeg_close(value ctx)
{
  CAMLparam1(ctx);

  if (Context_val(ctx)->fmtCtx) {
    AVFormatContext* fmtCtx = Context_val(ctx)->fmtCtx;
    caml_enter_blocking_section();
    if (fmtCtx->pb) {
      av_write_trailer(fmtCtx);
    }
    //avcodec_close(Context_val(ctx)->avstream->codec); ??
    avformat_free_context(fmtCtx);

    if (!(fmtCtx->flags & AVFMT_NOFILE)) {
      int ret = avio_close(fmtCtx->pb);
      raise_and_leave_blocking_section_if_not(ret >= 0, ExnFileIO, ret);
    }

    caml_leave_blocking_section();
    Context_val(ctx)->fmtCtx = NULL;
    free(Context_val(ctx)->filename);
    Context_val(ctx)->filename = NULL;
  }
  
  CAMLreturn(Val_unit);
}
开发者ID:eras,项目名称:webcamviewer,代码行数:27,代码来源:ffmpeg-stubs.c

示例4: NAME

CAMLprim value NAME(value vCMP, value vN,
                    value vOFSX, value vINCX, value vX)
{
  CAMLparam2(vCMP, vX);
#if defined(OCAML_SORT_CALLBACK)
  CAMLlocal2(va, vb);
#endif
  const size_t GET_INT(N);
  int GET_INT(INCX);
  VEC_PARAMS(X);

  NUMBER *const base_ptr = X_data;
  const size_t max_thresh = MAX_THRESH * sizeof(NUMBER) * INCX;

  if (N == 0) CAMLreturn(Val_unit);

#ifndef OCAML_SORT_CALLBACK
  caml_enter_blocking_section();  /* Allow other threads */
#endif

#define QUICKSORT_LT(a, b) OCAML_SORT_LT((*a), (*b))
  QUICKSORT(NUMBER, base_ptr, INCX, max_thresh);
#undef QUICKSORT_LT

#ifndef OCAML_SORT_CALLBACK
  caml_leave_blocking_section();  /* Disallow other threads */
#endif

  CAMLreturn(Val_unit);
}
开发者ID:akabe,项目名称:lacaml,代码行数:30,代码来源:vec_sort.c

示例5: mlptrace_peek

value
mlptrace_peek (value pid_v, value adr_v)
{
  pid_t pid;
  long adr;
  long r;
  int savederrno = errno;
  CAMLparam2 (pid_v, adr_v);
  CAMLlocal1 (res_v);
  pid = Long_val (pid_v);
  adr = Nativeint_val (adr_v);
#ifndef NO_BLOCKING_SECTION
  caml_enter_blocking_section ();
#endif
  r = ptrace (PTRACE_PEEKDATA, pid, adr, 0);
#ifndef NO_BLOCKING_SECTION
  caml_leave_blocking_section ();
#endif
  if (r == -1 && errno)
    uerror ("Ptrace.peek", Nothing);
  if (savederrno)
    errno = savederrno;
  res_v = caml_copy_nativeint (r);
  CAMLreturn (res_v);
}
开发者ID:bmeurer,项目名称:ocamljitrun,代码行数:25,代码来源:mlptrace.c

示例6: bin_prot_blit_buf_stub

CAMLprim value bin_prot_blit_buf_stub(
  value v_src_pos, value v_src, value v_dst_pos, value v_dst, value v_len)
{
  struct caml_ba_array *ba_src = Caml_ba_array_val(v_src);
  struct caml_ba_array *ba_dst = Caml_ba_array_val(v_dst);
  char *src = (char *) ba_src->data + Long_val(v_src_pos);
  char *dst = (char *) ba_dst->data + Long_val(v_dst_pos);
  size_t len = (size_t) Long_val(v_len);
  if
    (
      unlikely(len > 65536)
      || unlikely(((ba_src->flags & CAML_BA_MAPPED_FILE) != 0))
      || unlikely(((ba_dst->flags & CAML_BA_MAPPED_FILE) != 0))
    )
  /* use [memmove] rather than [memcpy] because src and dst may overlap */
  {
    Begin_roots2(v_src, v_dst);
    caml_enter_blocking_section();
      memmove(dst, src, len);
    caml_leave_blocking_section();
    End_roots();
  }
  else memmove(dst, src, len);
  return Val_unit;
}
开发者ID:camlspotter,项目名称:ocaml-mingw,代码行数:25,代码来源:blit_stubs.c

示例7: caml_sqlite3_exec

CAMLprim value caml_sqlite3_exec(value v_db, value v_maybe_cb, value v_sql)
{
  CAMLparam1(v_db);
  CAMLlocal2(v_cb, v_exn);
  callback_with_exn cbx;
  db_wrap *dbw = Sqlite3_val(v_db);
  int len = caml_string_length(v_sql) + 1;
  char *sql;
  int rc;
  sqlite3_callback cb = NULL;

  check_db(dbw, "exec");
  sql = caml_stat_alloc(len);
  memcpy(sql, String_val(v_sql), len);
  cbx.cbp = &v_cb;
  cbx.exn = &v_exn;

  if (v_maybe_cb != Val_None) {
    v_cb = Field(v_maybe_cb, 0);
    cb = exec_callback;
  }

  caml_enter_blocking_section();
    rc = sqlite3_exec(dbw->db, sql, cb, (void *) &cbx, NULL);
    free(sql);
  caml_leave_blocking_section();

  if (rc == SQLITE_ABORT) caml_raise(*cbx.exn);

  CAMLreturn(Val_rc(rc));
}
开发者ID:Moondee,项目名称:caut-lib,代码行数:31,代码来源:sqlite3_stubs.c

示例8: caml_sqlite3_exec_not_null_no_headers

CAMLprim value caml_sqlite3_exec_not_null_no_headers(
  value v_db, value v_cb, value v_sql)
{
  CAMLparam2(v_db, v_cb);
  CAMLlocal1(v_exn);
  callback_with_exn cbx;
  db_wrap *dbw = Sqlite3_val(v_db);
  int len = caml_string_length(v_sql) + 1;
  char *sql;
  int rc;

  check_db(dbw, "exec_not_null_no_headers");
  sql = caml_stat_alloc(len);
  memcpy(sql, String_val(v_sql), len);
  cbx.cbp = &v_cb;
  cbx.exn = &v_exn;

  caml_enter_blocking_section();
    rc =
      sqlite3_exec(
        dbw->db, sql, exec_not_null_no_headers_callback, (void *) &cbx, NULL);
    free(sql);
  caml_leave_blocking_section();

  if (rc == SQLITE_ABORT) {
    if (*cbx.exn != 0) caml_raise(*cbx.exn);
    else raise_sqlite3_Error("Null element in row");
  }
  CAMLreturn(Val_rc(rc));
}
开发者ID:Moondee,项目名称:caut-lib,代码行数:30,代码来源:sqlite3_stubs.c

示例9: do_write

static int do_write(int fd, char *p, int n)
{
  int retcode;
again:
  caml_enter_blocking_section();

  // Changed!!!
  if ((fd == 1/*stdout*/ || fd == 2/*stderr*/) && custom_ocaml_stdout_func)
  {
	  (*custom_ocaml_stdout_func)(fd, p, n);
	  retcode = n;
  }
  else
	  retcode = write(fd, p, n);

  caml_leave_blocking_section();
  if (retcode == -1) {
    if (errno == EINTR) goto again;
    if ((errno == EAGAIN || errno == EWOULDBLOCK) && n > 1) {
      /* We couldn't do a partial write here, probably because
         n <= PIPE_BUF and POSIX says that writes of less than
         PIPE_BUF characters must be atomic.
         We first try again with a partial write of 1 character.
         If that fails too, we'll raise Sys_blocked_io below. */
      n = 1; goto again;
    }
  }
  if (retcode == -1) caml_sys_io_error(NO_ARG);
  return retcode;
}
开发者ID:joechenq,项目名称:multi-script,代码行数:30,代码来源:ocaml_io.c

示例10: caml_bjack_read

CAMLprim value caml_bjack_read(value device, value len)
{
    CAMLparam2(device,len);
    CAMLlocal1(ans);
    int n = Int_val(len) ;
    char* buf = malloc(n) ;
    jack_driver_t* drv = Bjack_drv_val(device);
    long ret;

    if (drv->num_input_channels > 0)
    {
        caml_enter_blocking_section();
        ret = JACK_Read(drv,(unsigned char *)buf,n);
        caml_leave_blocking_section();
    }
    else
    {
        caml_raise_constant(*caml_named_value("bio2jack_exn_too_many_input_channels"));
    }

    if (ret < 0) caml_failwith("jack_read");

    ans = caml_alloc_string(ret);
    memcpy(String_val(ans),buf,ret);
    free(buf);

    CAMLreturn(ans);
}
开发者ID:savonet,项目名称:ocaml-bjack,代码行数:28,代码来源:jack_stubs.c

示例11: statvfs_stub

CAMLprim value statvfs_stub (value v_path)
{
  CAMLparam1(v_path);
  CAMLlocal1(v_stat);
  struct statvfs s;
  int ret, len = caml_string_length(v_path) + 1;
  char *pathname = caml_stat_alloc(len);
  memcpy(pathname, String_val(v_path), len);
  caml_enter_blocking_section();
  ret = statvfs(pathname,&s);
  caml_leave_blocking_section();
  caml_stat_free(pathname);
  if (ret != 0) uerror("statvfs",v_path);
  v_stat = caml_alloc(11, 0);
  Store_field(v_stat, 0, Val_int(s.f_bsize));
  Store_field(v_stat, 1, Val_int(s.f_frsize));
  Store_field(v_stat, 2, Val_int(s.f_blocks));
  Store_field(v_stat, 3, Val_int(s.f_bfree));
  Store_field(v_stat, 4, Val_int(s.f_bavail));
  Store_field(v_stat, 5, Val_int(s.f_files));
  Store_field(v_stat, 6, Val_int(s.f_ffree));
  Store_field(v_stat, 7, Val_int(s.f_favail));
  Store_field(v_stat, 8, Val_int(s.f_fsid));
  Store_field(v_stat, 9, Val_int(s.f_flag));
  Store_field(v_stat,10, Val_int(s.f_namemax));
  CAMLreturn(v_stat);
}
开发者ID:janestreet,项目名称:core_extended,代码行数:27,代码来源:extended_unix_stubs.c

示例12: LFUN

CAMLprim value LFUN(linspace_stub)(value vY, value va, value vb, value vN)
{
  CAMLparam1(vY);
  integer i, GET_INT(N);
  REAL ar = Double_field(va, 0),
       ai = Double_field(va, 1),
       N1 = N - 1.,
       hr = (Double_field(vb, 0) - ar) / N1,
       hi = (Double_field(vb, 1) - ai) / N1,
       xr = ar,
       xi = ai;
  VEC_PARAMS1(Y);

  caml_enter_blocking_section();  /* Allow other threads */

  for (i = 1; i <= N; i++) {
    Y_data->r = xr;
    Y_data->i = xi;
    Y_data++;
    xr = ar + i * hr;
    xi = ai + i * hi;
  }

  caml_leave_blocking_section();  /* Disallow other threads */

  CAMLreturn(Val_unit);
}
开发者ID:kkirstein,项目名称:lacaml,代码行数:27,代码来源:vec_CZ_c.c

示例13: ffmpeg_stream_close

value
ffmpeg_stream_close(value stream)
{
  CAMLparam1(stream);

  if (Stream_context_direct_val(stream) != Val_int(0)) {
    if (Stream_context_val(stream)->fmtCtx &&
        Stream_aux_val(stream)->avstream->codec->flags & AV_CODEC_CAP_DELAY) {
      int gotIt;
      AVPacket packet = { 0 };
      caml_enter_blocking_section();
      do {
        int ret = avcodec_encode_video2(Stream_aux_val(stream)->avstream->codec, &packet, NULL, &gotIt);
        raise_and_leave_blocking_section_if_not(ret >= 0, ExnEncode, ret);
        if (gotIt) {
          packet.stream_index = 0;
          ret = av_interleaved_write_frame(Stream_context_val(stream)->fmtCtx, &packet);
          raise_and_leave_blocking_section_if_not(ret >= 0, ExnFileIO, ret);
        }
      } while (gotIt);
      caml_leave_blocking_section();
    }

    avcodec_close(Stream_aux_val(stream)->avstream->codec);
    if (Stream_aux_val(stream)->swsCtx) {
      sws_freeContext(Stream_aux_val(stream)->swsCtx);
    }
    Stream_context_direct_val(stream) = Val_int(0);
 } else {
    raise(ExnClosed, 0);
  }

  CAMLreturn(Val_unit);
}
开发者ID:eras,项目名称:webcamviewer,代码行数:34,代码来源:ffmpeg-stubs.c

示例14: caml_bjack_write

CAMLprim value caml_bjack_write(value device, value data)
{
    CAMLparam2(device,data);
    int n = caml_string_length(data) ;
    jack_driver_t* drv = Bjack_drv_val(device);
    long ret;
    char* buf = malloc(n) ;
    memcpy(buf,String_val(data),n);

    if (drv->num_output_channels > 0)
    {
        caml_enter_blocking_section();
        ret = JACK_Write(drv,(unsigned char *)buf,n);
        caml_leave_blocking_section();
    }
    else
    {
        caml_raise_constant(*caml_named_value("bio2jack_exn_too_many_output_channels"));
    }

    if (ret < 0) caml_failwith("jack_write");

    free(buf);

    CAMLreturn(Val_long(ret));
}
开发者ID:savonet,项目名称:ocaml-bjack,代码行数:26,代码来源:jack_stubs.c

示例15: caml_sys_close

CAMLprim value caml_sys_close(value fd)
{
  caml_enter_blocking_section();
  close(Int_val(fd));
  caml_leave_blocking_section();
  return Val_unit;
}
开发者ID:BrianMulhall,项目名称:ocaml,代码行数:7,代码来源:sys.c


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