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


C++ s_lock函数代码示例

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


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

示例1: lagopus_cbuffer_clear

lagopus_result_t
lagopus_cbuffer_clear(lagopus_cbuffer_t *cbptr,
                      bool free_values) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;

  if (cbptr != NULL &&
      *cbptr != NULL) {

    s_lock(*cbptr);
    {
      s_clean(*cbptr, free_values);
      if ((*cbptr)->m_qmuxer != NULL &&
          NEED_WAIT_READABLE((*cbptr)->m_type) == true) {
        qmuxer_notify((*cbptr)->m_qmuxer);
      }
      (void)lagopus_cond_notify(&((*cbptr)->m_cond_put), true);
    }
    s_unlock(*cbptr);

    ret = LAGOPUS_RESULT_OK;

  } else {
    ret = LAGOPUS_RESULT_INVALID_ARGS;
  }

  return ret;
}
开发者ID:1514louluo,项目名称:lagopus,代码行数:27,代码来源:cbuffer.c

示例2: s_do_log

static inline void
s_do_log(lagopus_log_level_t l, const char *msg) {
  FILE *fd;
  int o_cancel_state;

  (void)pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &o_cancel_state);

  s_lock();

  switch (s_log_dst) {
    case LAGOPUS_LOG_EMIT_TO_FILE:
    case LAGOPUS_LOG_EMIT_TO_UNKNOWN: {
      fd = (s_log_fd != NULL) ? s_log_fd : stderr;
      (void)fprintf(fd, "%s", msg);
      (void)fflush(fd);
      break;
    }
    case LAGOPUS_LOG_EMIT_TO_SYSLOG: {
      int prio = s_get_syslog_priority(l);
      syslog(prio, "%s", msg);
    }
  }

  s_unlock();

  (void)pthread_setcancelstate(o_cancel_state, NULL);
}
开发者ID:D-TOKIOKA,项目名称:lagopus,代码行数:27,代码来源:logger.c

示例3: lagopus_cbuffer_wait_puttable

lagopus_result_t
lagopus_cbuffer_wait_puttable(lagopus_cbuffer_t *cbptr,
                              lagopus_chrono_t nsec) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;
  int64_t remains;

  if (cbptr != NULL && *cbptr != NULL) {

    s_lock(*cbptr);
    {
      remains = (*cbptr)->m_n_max_elements - (*cbptr)->m_n_elements;
      if (remains > 0) {
        ret = (lagopus_result_t)remains;
      } else {
        ret = s_wait_puttable(*cbptr, nsec);
        if (ret == LAGOPUS_RESULT_OK) {
          ret = (*cbptr)->m_n_max_elements - (*cbptr)->m_n_elements;
        }
      }
    }
    s_unlock(*cbptr);

  } else {
    ret = LAGOPUS_RESULT_INVALID_ARGS;
  }

  return ret;
}
开发者ID:1514louluo,项目名称:lagopus,代码行数:28,代码来源:cbuffer.c

示例4: s_lock

shared_ptr<GlobalVariable> VariableRegistry::createGlobalVariable(VariableProperties *props) {
    boost::mutex::scoped_lock s_lock(lock);

	shared_ptr<GlobalVariable> var = addGlobalVariable(props);
	
	return var;
}
开发者ID:maunsell,项目名称:mworks-1,代码行数:7,代码来源:VariableRegistry.cpp

示例5: dummy_module_shutdown

static lagopus_result_t
dummy_module_shutdown(shutdown_grace_level_t l) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;

  lagopus_msg_debug(5, "called.\n");

  if (s_thd != NULL) {

    s_lock();
    {
      if (s_is_initialized == true) {
        if (l == SHUTDOWN_GRACEFULLY) {
          s_is_gracefull = true;
        }
        s_do_loop = false;
        ret = LAGOPUS_RESULT_OK;
      } else {
        ret = LAGOPUS_RESULT_INVALID_STATE_TRANSITION;
      }
    }
    s_unlock();

  } else {
    ret = LAGOPUS_RESULT_INVALID_OBJECT;
  }

  return ret;
}
开发者ID:AkiraSuu,项目名称:lagopus,代码行数:28,代码来源:dummy-module.c

示例6: dummy_module_start

static lagopus_result_t
dummy_module_start(void) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;

  lagopus_msg_debug(5, "called.\n");

  if (s_thd != NULL) {

    s_lock();
    {
      if (s_is_initialized == true) {
        ret = lagopus_thread_start(&s_thd, false);
        if (ret == LAGOPUS_RESULT_OK) {
          s_do_loop = true;
        }
      } else {
        ret = LAGOPUS_RESULT_INVALID_STATE_TRANSITION;
      }
    }
    s_unlock();

  } else {
    ret = LAGOPUS_RESULT_INVALID_OBJECT;
  }

  return ret;
}
开发者ID:AkiraSuu,项目名称:lagopus,代码行数:27,代码来源:dummy-module.c

示例7: gallus_module_finalize_all

void
gallus_module_finalize_all(void) {
  s_lock();
  {

    s_gstate = MODULE_GLOBAL_STATE_FINALIZING;

    if (s_n_modules > 0) {
      size_t i;
      a_module *mptr;

      /*
       * Reverse order.
       */
      for (i = 0; i < s_n_modules; i++) {
        mptr = &(s_modules[s_n_modules - i - 1]);
        s_finalize_module(mptr);
      }
    }

    s_gstate = MODULE_GLOBAL_STATE_FINALIZED;

    s_wakeup();
  }
  s_unlock();
}
开发者ID:uTnOJkji5quPSNE5,项目名称:gallus,代码行数:26,代码来源:module.c

示例8: gallus_module_register

gallus_result_t
gallus_module_register(const char *name,
                        gallus_module_initialize_proc_t init_proc,
                        void *extarg,
                        gallus_module_start_proc_t start_proc,
                        gallus_module_shutdown_proc_t shutdown_proc,
                        gallus_module_stop_proc_t stop_proc,
                        gallus_module_finalize_proc_t finalize_proc,
                        gallus_module_usage_proc_t usage_proc) {
  gallus_result_t ret = GALLUS_RESULT_ANY_FAILURES;

  s_lock();
  {
    ret = s_register_module(name,
                            init_proc, extarg,
                            start_proc,
                            shutdown_proc,
                            stop_proc,
                            finalize_proc,
                            usage_proc);
  }
  s_unlock();

  return ret;
}
开发者ID:uTnOJkji5quPSNE5,项目名称:gallus,代码行数:25,代码来源:module.c

示例9: lagopus_module_start_all

lagopus_result_t
lagopus_module_start_all(void) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;

  s_lock();
  {
    if (s_n_modules > 0) {
      size_t i;
      a_module *mptr;

      for (ret = LAGOPUS_RESULT_OK, i = 0;
           ret == LAGOPUS_RESULT_OK && i < s_n_modules;
           i++) {
        mptr = &(s_modules[i]);
        ret = s_start_module(mptr);
        if (ret != LAGOPUS_RESULT_OK) {
          lagopus_perror(ret);
          lagopus_msg_error("can't start module \"%s\".\n",
                            mptr->m_name);
        }
      }
    } else {
      ret = LAGOPUS_RESULT_OK;
    }
  }
  s_unlock();

  return ret;
}
开发者ID:D-TOKIOKA,项目名称:lagopus,代码行数:29,代码来源:module.c

示例10: lagopus_module_initialize_all

lagopus_result_t
lagopus_module_initialize_all(int argc, const char *const argv[]) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;

  s_lock();
  {
    if (s_n_modules > 0) {
      size_t i;
      a_module *mptr;

      for (ret = LAGOPUS_RESULT_OK, i = 0;
           ret == LAGOPUS_RESULT_OK && i < s_n_modules;
           i++) {
        mptr = &(s_modules[i]);
        ret = s_initialize_module(mptr, argc, argv);
        if (ret != LAGOPUS_RESULT_OK) {
          lagopus_perror(ret);
          lagopus_msg_error("can't initialize module \"%s\".\n",
                            mptr->m_name);
        }
      }
    } else {
      ret = LAGOPUS_RESULT_OK;
    }
  }
  s_unlock();

  return ret;
}
开发者ID:D-TOKIOKA,项目名称:lagopus,代码行数:29,代码来源:module.c

示例11: aa_sdl_handle_event

AA_API int
aa_sdl_handle_event( const SDL_Event *event,
                     struct aa_sdl_display_params *params)
{
    s_lock();

    struct handler *r = NULL;

    if( SDL_KEYDOWN == event->type ) {
        /* search for key */
        SDL_Keycode key = event->key.keysym.sym;
        for( size_t i = 0; !r && i < s_key_vector.size; i ++ ) {
            struct handler *h = s_key_vector.data[i];
            if( key == h->key ) r = h;
        }
    } else {
        /* search for event */
        for( size_t i = 0; !r && i < s_event_vector.size; i ++ ) {
            struct handler *h = s_event_vector.data[i];
            if( event->type == h->event_type ) r = h;
        }
    }

    s_unlock();

    return (r
            ? r->handler(r->cx, params)
            : -1);
}
开发者ID:golems,项目名称:amino,代码行数:29,代码来源:sdl_handler.c

示例12: lagopus_cbuffer_is_empty

lagopus_result_t
lagopus_cbuffer_is_empty(lagopus_cbuffer_t *cbptr, bool *retptr) {
  lagopus_result_t ret = LAGOPUS_RESULT_ANY_FAILURES;

  if (cbptr != NULL &&
      *cbptr != NULL &&
      retptr != NULL) {
    *retptr = false;

    s_lock(*cbptr);
    {
      if ((*cbptr)->m_is_operational == true) {
        *retptr = ((*cbptr)->m_n_elements == 0) ? true : false;
        ret = LAGOPUS_RESULT_OK;
      } else {
        ret = LAGOPUS_RESULT_NOT_OPERATIONAL;
      }
    }
    s_unlock(*cbptr);

  } else {
    ret = LAGOPUS_RESULT_INVALID_ARGS;
  }

  return ret;
}
开发者ID:1514louluo,项目名称:lagopus,代码行数:26,代码来源:cbuffer.c

示例13: global_state_reset

void
global_state_reset(void) {
  s_lock();
  {
    s_gs = GLOBAL_STATE_UNKNOWN;
  }
  s_unlock();
}
开发者ID:1514louluo,项目名称:lagopus,代码行数:8,代码来源:gstate.c

示例14: add_acc_session

/**
 * Creates and adds an accounting session to the hash table.
 * \note Locks the hash slot if OK! Call s_unlock(acc_session->hash) when you are finished)
 * @param s - AAAAcctSession to add
 * @returns the new AAAAcctSession* or NULL
 */
AAAAcctSession* add_acc_session(AAAAcctSession* s)
{
	s_lock(s->hash);
		s->next = 0;
		s->prev = acc_sessions[s->hash].tail;
		if (s->prev) s->prev->next = s;
		acc_sessions[s->hash].tail = s;
		if (!acc_sessions[s->hash].head) acc_sessions[s->hash].head = s;

		return s;
}
开发者ID:asyn,项目名称:openvims,代码行数:17,代码来源:acct.c

示例15: gallus_module_shutdown_all

gallus_result_t
gallus_module_shutdown_all(shutdown_grace_level_t level) {
  gallus_result_t ret = GALLUS_RESULT_ANY_FAILURES;

  if (IS_VALID_SHUTDOWN(level) == true) {

    s_lock();
    {

      s_gstate = MODULE_GLOBAL_STATE_SHUTTINGDOWN;

      if (s_n_modules > 0) {
        gallus_result_t first_err = GALLUS_RESULT_OK;
        size_t i;
        a_module *mptr;

        /*
         * Reverse order.
         */
        for (i = 0; i < s_n_modules; i++) {
          mptr = &(s_modules[s_n_modules - i - 1]);
          ret = s_shutdown_module(mptr, level);
          if (ret != GALLUS_RESULT_OK) {
            gallus_perror(ret);
            gallus_msg_error("can't shutdown module \"%s\".\n",
                              mptr->m_name);
            if (first_err == GALLUS_RESULT_OK) {
              first_err = ret;
            }
          }
          /*
           * Just carry on shutting down no matter what kind of errors
           * occur.
           */
        }

        ret = first_err;

      } else {
        ret = GALLUS_RESULT_OK;
      }

    }
    s_unlock();

  } else {
    ret = GALLUS_RESULT_INVALID_ARGS;
  }

  return ret;
}
开发者ID:uTnOJkji5quPSNE5,项目名称:gallus,代码行数:51,代码来源:module.c


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