Пример #1
0
cl_status_t
cl_timer_init(IN cl_timer_t * const p_timer,
	      IN cl_pfn_timer_callback_t pfn_callback,
	      IN const void *const context)
{
	CL_ASSERT(p_timer);
	CL_ASSERT(pfn_callback);

	cl_timer_construct(p_timer);

	if (!gp_timer_prov)
		return (CL_ERROR);

	/* Store timer parameters. */
	p_timer->pfn_callback = pfn_callback;
	p_timer->context = context;

	/* Mark the timer as idle. */
	p_timer->timer_state = CL_TIMER_IDLE;

	/* Create the condition variable that is used when cancelling a timer. */
	pthread_cond_init(&p_timer->cond, NULL);

	p_timer->state = CL_INITIALIZED;

	return (CL_SUCCESS);
}
Пример #2
0
void osm_sa_construct(IN osm_sa_t * p_sa)
{
	memset(p_sa, 0, sizeof(*p_sa));
	p_sa->state = OSM_SA_STATE_INIT;
	p_sa->sa_trans_id = OSM_SA_INITIAL_TID_VALUE;

	cl_timer_construct(&p_sa->sr_timer);
}
Пример #3
0
void osm_transaction_mgr_init(IN osm_vendor_t * const p_vend)
{
	cl_status_t cl_status;
	osm_transaction_mgr_t *trans_mgr_p;
	OSM_LOG_ENTER(p_vend->p_log);

	CL_ASSERT(p_vend->p_transaction_mgr == NULL);

	(osm_transaction_mgr_t *) p_vend->p_transaction_mgr =
	    (osm_transaction_mgr_t *) malloc(sizeof(osm_transaction_mgr_t));

	trans_mgr_p = (osm_transaction_mgr_t *) p_vend->p_transaction_mgr;

	/*  construct lock object  */
	cl_spinlock_construct(&(trans_mgr_p->transaction_mgr_lock));
	CL_ASSERT(cl_spinlock_init(&(trans_mgr_p->transaction_mgr_lock)) ==
		  CL_SUCCESS);

	/*  initialize the qlist */
	trans_mgr_p->madw_reqs_list_p =
	    (cl_qlist_t *) malloc(sizeof(cl_qlist_t));
	cl_qlist_init(trans_mgr_p->madw_reqs_list_p);

	/*  initialize the qmap */
	trans_mgr_p->madw_by_tid_map_p =
	    (cl_qmap_t *) malloc(sizeof(cl_qmap_t));
	cl_qmap_init(trans_mgr_p->madw_by_tid_map_p);

	/*  create the timer used by the madw_req_list */
	cl_timer_construct(&(trans_mgr_p->madw_list_timer));

	/*  init the timer with timeout. */
	cl_status = cl_timer_init(&trans_mgr_p->madw_list_timer,
				  __osm_transaction_mgr_callback, p_vend);

	if (cl_status != CL_SUCCESS) {
		osm_log(p_vend->p_log, OSM_LOG_ERROR,
			"osm_transaction_mgr_init : ERROR 1000: "
			"Failed to initialize madw_reqs_list timer\n");
	}
	OSM_LOG_EXIT(p_vend->p_log);
}
Пример #4
0
/*
 * Construct and Initialize
 */
void cl_event_wheel_construct(IN cl_event_wheel_t * const p_event_wheel)
{
	cl_spinlock_construct(&(p_event_wheel->lock));
	cl_timer_construct(&(p_event_wheel->timer));
}