Blame include/complib/cl_dispatcher.h

Packit 13e616
/*
Packit 13e616
 * Copyright (c) 2004, 2005 Voltaire, Inc. All rights reserved.
Packit 13e616
 * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
Packit 13e616
 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
Packit 13e616
 *
Packit 13e616
 * This software is available to you under a choice of one of two
Packit 13e616
 * licenses.  You may choose to be licensed under the terms of the GNU
Packit 13e616
 * General Public License (GPL) Version 2, available from the file
Packit 13e616
 * COPYING in the main directory of this source tree, or the
Packit 13e616
 * OpenIB.org BSD license below:
Packit 13e616
 *
Packit 13e616
 *     Redistribution and use in source and binary forms, with or
Packit 13e616
 *     without modification, are permitted provided that the following
Packit 13e616
 *     conditions are met:
Packit 13e616
 *
Packit 13e616
 *      - Redistributions of source code must retain the above
Packit 13e616
 *        copyright notice, this list of conditions and the following
Packit 13e616
 *        disclaimer.
Packit 13e616
 *
Packit 13e616
 *      - Redistributions in binary form must reproduce the above
Packit 13e616
 *        copyright notice, this list of conditions and the following
Packit 13e616
 *        disclaimer in the documentation and/or other materials
Packit 13e616
 *        provided with the distribution.
Packit 13e616
 *
Packit 13e616
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Packit 13e616
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Packit 13e616
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Packit 13e616
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
Packit 13e616
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
Packit 13e616
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
Packit 13e616
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Packit 13e616
 * SOFTWARE.
Packit 13e616
 *
Packit 13e616
 */
Packit 13e616
Packit 13e616
/*
Packit 13e616
 * Abstract:
Packit 13e616
 * 	Declaration of dispatcher abstraction.
Packit 13e616
 */
Packit 13e616
Packit 13e616
#ifndef _CL_DISPATCHER_H_
Packit 13e616
#define _CL_DISPATCHER_H_
Packit 13e616
Packit 13e616
#include <complib/cl_atomic.h>
Packit 13e616
#include <complib/cl_threadpool.h>
Packit 13e616
#include <complib/cl_qlist.h>
Packit 13e616
#include <complib/cl_qpool.h>
Packit 13e616
#include <complib/cl_spinlock.h>
Packit 13e616
#include <complib/cl_ptr_vector.h>
Packit 13e616
Packit 13e616
#ifdef __cplusplus
Packit 13e616
#  define BEGIN_C_DECLS extern "C" {
Packit 13e616
#  define END_C_DECLS   }
Packit 13e616
#else				/* !__cplusplus */
Packit 13e616
#  define BEGIN_C_DECLS
Packit 13e616
#  define END_C_DECLS
Packit 13e616
#endif				/* __cplusplus */
Packit 13e616
Packit 13e616
BEGIN_C_DECLS
Packit 13e616
/****h* Component Library/Dispatcher
Packit 13e616
* NAME
Packit 13e616
*	Dispatcher
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	The Dispatcher provides a facility for message routing to
Packit 13e616
*	asynchronous worker threads.
Packit 13e616
*
Packit 13e616
*	The Dispatcher functions operate on a cl_dispatcher_t structure
Packit 13e616
*	which should be treated as opaque and should be manipulated
Packit 13e616
*	only through the provided functions.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Structures:
Packit 13e616
*		cl_dispatcher_t
Packit 13e616
*
Packit 13e616
*	Initialization/Destruction:
Packit 13e616
*		cl_disp_construct, cl_disp_init, cl_disp_shutdown, cl_disp_destroy
Packit 13e616
*
Packit 13e616
*	Manipulation:
Packit 13e616
*		cl_disp_post, cl_disp_register, cl_disp_unregister
Packit 13e616
*********/
Packit 13e616
/****s* Component Library: Dispatcher/cl_disp_msgid_t
Packit 13e616
* NAME
Packit 13e616
*	cl_disp_msgid_t
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	Defines the type of dispatcher messages.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
typedef uint32_t cl_disp_msgid_t;
Packit 13e616
/**********/
Packit 13e616
Packit 13e616
/****s* Component Library: Dispatcher/CL_DISP_MSGID_NONE
Packit 13e616
* NAME
Packit 13e616
*	CL_DISP_MSGID_NONE
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	Defines a message value that means "no message".
Packit 13e616
*	This value is used during registration by Dispatcher clients
Packit 13e616
*	that do not wish to receive messages.
Packit 13e616
*
Packit 13e616
*	No Dispatcher message is allowed to have this value.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
#define CL_DISP_MSGID_NONE	0xFFFFFFFF
Packit 13e616
/**********/
Packit 13e616
Packit 13e616
/****s* Component Library: Dispatcher/CL_DISP_INVALID_HANDLE
Packit 13e616
* NAME
Packit 13e616
*	CL_DISP_INVALID_HANDLE
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	Defines the value of an invalid Dispatcher registration handle.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
#define CL_DISP_INVALID_HANDLE ((cl_disp_reg_handle_t)0)
Packit 13e616
/*********/
Packit 13e616
Packit 13e616
/****f* Component Library: Dispatcher/cl_pfn_msgrcv_cb_t
Packit 13e616
* NAME
Packit 13e616
*	cl_pfn_msgrcv_cb_t
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	This typedef defines the prototype for client functions invoked
Packit 13e616
*	by the Dispatcher.  The Dispatcher calls the corresponding
Packit 13e616
*	client function when delivering a message to the client.
Packit 13e616
*
Packit 13e616
*	The client function must be reentrant if the user creates a
Packit 13e616
*	Dispatcher with more than one worker thread.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
typedef void
Packit 13e616
 (*cl_pfn_msgrcv_cb_t) (IN void *context, IN void *p_data);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	context
Packit 13e616
*		[in] Client specific context specified in a call to
Packit 13e616
*		cl_disp_register
Packit 13e616
*
Packit 13e616
*	p_data
Packit 13e616
*		[in] Pointer to the client specific data payload
Packit 13e616
*		of this message.
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	This function does not return a value.
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*	This typedef provides a function prototype reference for
Packit 13e616
*	the function provided by Dispatcher clients as a parameter
Packit 13e616
*	to the cl_disp_register function.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Dispatcher, cl_disp_register
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* Component Library: Dispatcher/cl_pfn_msgdone_cb_t
Packit 13e616
* NAME
Packit 13e616
*	cl_pfn_msgdone_cb_t
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	This typedef defines the prototype for client functions invoked
Packit 13e616
*	by the Dispatcher.  The Dispatcher calls the corresponding
Packit 13e616
*	client function after completing delivery of a message.
Packit 13e616
*
Packit 13e616
*	The client function must be reentrant if the user creates a
Packit 13e616
*	Dispatcher with more than one worker thread.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
typedef void
Packit 13e616
 (*cl_pfn_msgdone_cb_t) (IN void *context, IN void *p_data);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	context
Packit 13e616
*		[in] Client specific context specified in a call to
Packit 13e616
*		cl_disp_post
Packit 13e616
*
Packit 13e616
*	p_data
Packit 13e616
*		[in] Pointer to the client specific data payload
Packit 13e616
*		of this message.
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	This function does not return a value.
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*	This typedef provides a function prototype reference for
Packit 13e616
*	the function provided by Dispatcher clients as a parameter
Packit 13e616
*	to the cl_disp_post function.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Dispatcher, cl_disp_post
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****s* Component Library: Dispatcher/cl_dispatcher_t
Packit 13e616
* NAME
Packit 13e616
*	cl_dispatcher_t
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	Dispatcher structure.
Packit 13e616
*
Packit 13e616
*	The Dispatcher is thread safe.
Packit 13e616
*
Packit 13e616
*	The cl_dispatcher_t structure should be treated as opaque and should
Packit 13e616
*	be manipulated only through the provided functions.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
typedef struct _cl_dispatcher {
Packit 13e616
	cl_spinlock_t lock;
Packit 13e616
	cl_ptr_vector_t reg_vec;
Packit 13e616
	cl_qlist_t reg_list;
Packit 13e616
	cl_thread_pool_t worker_threads;
Packit 13e616
	cl_qlist_t msg_fifo;
Packit 13e616
	cl_qpool_t msg_pool;
Packit 13e616
	uint64_t last_msg_queue_time_us;
Packit 13e616
} cl_dispatcher_t;
Packit 13e616
/*
Packit 13e616
* FIELDS
Packit 13e616
*	lock
Packit 13e616
*		Spinlock to guard internal structures.
Packit 13e616
*
Packit 13e616
*	reg_vec
Packit 13e616
*		Vector of registration info objects.  Indexed by message msg_id.
Packit 13e616
*
Packit 13e616
*	reg_list
Packit 13e616
*		List of registration info objects.
Packit 13e616
*
Packit 13e616
*	worker_threads
Packit 13e616
*		Thread pool of worker threads to dispose of posted messages.
Packit 13e616
*
Packit 13e616
*	msg_fifo
Packit 13e616
*		FIFO of messages being processed by the Dispatcher.  New
Packit 13e616
*		messages are posted to the tail of the FIFO.  Worker threads
Packit 13e616
*		pull messages from the front.
Packit 13e616
*
Packit 13e616
*	msg_pool
Packit 13e616
*		Pool of message objects to be processed through the FIFO.
Packit 13e616
*
Packit 13e616
*	last_msg_queue_time_us
Packit 13e616
*		The time that the last message spent in the Q in usec
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Dispatcher
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****s* Component Library: Dispatcher/cl_disp_reg_info_t
Packit 13e616
* NAME
Packit 13e616
*	cl_disp_reg_info_t
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	Defines the dispatcher registration object structure.
Packit 13e616
*
Packit 13e616
*	The cl_disp_reg_info_t structure is for internal use by the
Packit 13e616
*	Dispatcher only.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
typedef struct _cl_disp_reg_info {
Packit 13e616
	cl_list_item_t list_item;
Packit 13e616
	cl_pfn_msgrcv_cb_t pfn_rcv_callback;
Packit 13e616
	const void *context;
Packit 13e616
	atomic32_t ref_cnt;
Packit 13e616
	cl_disp_msgid_t msg_id;
Packit 13e616
	cl_dispatcher_t *p_disp;
Packit 13e616
} cl_disp_reg_info_t;
Packit 13e616
/*
Packit 13e616
* FIELDS
Packit 13e616
* 	list_item
Packit 13e616
* 		List linkage.  Must be first element in the structure!!
Packit 13e616
*
Packit 13e616
*	pfn_rcv_callback
Packit 13e616
*		Client's message receive callback.
Packit 13e616
*
Packit 13e616
*	context
Packit 13e616
*		Client's context for message receive callback.
Packit 13e616
*
Packit 13e616
*	ref_cnt
Packit 13e616
*		Reference count.
Packit 13e616
*
Packit 13e616
*	msg_id
Packit 13e616
*		Dispatcher message msg_id value for this registration object.
Packit 13e616
*
Packit 13e616
*	p_disp
Packit 13e616
*		Pointer to parent Dispatcher.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****s* Component Library: Dispatcher/cl_disp_msg_t
Packit 13e616
* NAME
Packit 13e616
*	cl_disp_msg_t
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	Defines the dispatcher message structure.
Packit 13e616
*
Packit 13e616
*	The cl_disp_msg_t structure is for internal use by the
Packit 13e616
*	Dispatcher only.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
typedef struct _cl_disp_msg {
Packit 13e616
	cl_pool_item_t item;
Packit 13e616
	const void *p_data;
Packit 13e616
	cl_disp_reg_info_t *p_src_reg;
Packit 13e616
	cl_disp_reg_info_t *p_dest_reg;
Packit 13e616
	cl_pfn_msgdone_cb_t pfn_xmt_callback;
Packit 13e616
	uint64_t in_time;
Packit 13e616
	const void *context;
Packit 13e616
} cl_disp_msg_t;
Packit 13e616
/*
Packit 13e616
* FIELDS
Packit 13e616
*	item
Packit 13e616
*		List & Pool linkage.  Must be first element in the structure!!
Packit 13e616
*
Packit 13e616
*	p_data
Packit 13e616
*		Pointer to the data payload for this message.  The payload
Packit 13e616
*		is opaque to the Dispatcher.
Packit 13e616
*
Packit 13e616
*	p_src_reg
Packit 13e616
*		Pointer to the registration info of the sender.
Packit 13e616
*
Packit 13e616
* 	p_dest_reg
Packit 13e616
* 		Pointer to the registration info of the recipient.
Packit 13e616
*
Packit 13e616
*	pfn_xmt_callback
Packit 13e616
*		Client's message done callback.
Packit 13e616
*
Packit 13e616
*       in_time
Packit 13e616
*               The absolute time the message was inserted into the queue
Packit 13e616
*
Packit 13e616
*	context
Packit 13e616
*		Client's message done callback context.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****s* Component Library: Dispatcher/cl_disp_reg_info_t
Packit 13e616
* NAME
Packit 13e616
*	cl_disp_reg_info_t
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	Defines the Dispatcher registration handle.  This handle
Packit 13e616
*	should be treated as opaque by the client.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
typedef const struct _cl_disp_reg_info *cl_disp_reg_handle_t;
Packit 13e616
/**********/
Packit 13e616
Packit 13e616
/****f* Component Library: Dispatcher/cl_disp_construct
Packit 13e616
* NAME
Packit 13e616
*	cl_disp_construct
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	This function constructs a Dispatcher object.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
void cl_disp_construct(IN cl_dispatcher_t * const p_disp);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	p_disp
Packit 13e616
*		[in] Pointer to a Dispatcher.
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	This function does not return a value.
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*	Allows calling cl_disp_init and cl_disp_destroy.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Dispatcher, cl_disp_init, cl_disp_destroy
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* Component Library: Dispatcher/cl_disp_init
Packit 13e616
* NAME
Packit 13e616
*	cl_disp_init
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	This function initializes a Dispatcher object.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
cl_status_t
Packit 13e616
cl_disp_init(IN cl_dispatcher_t * const p_disp,
Packit 13e616
	     IN const uint32_t thread_count, IN const char *const name);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	p_disp
Packit 13e616
*		[in] Pointer to a Dispatcher.
Packit 13e616
*
Packit 13e616
*	thread_count
Packit 13e616
*		[in] The number of worker threads to create in this Dispatcher.
Packit 13e616
*		A value of 0 causes the Dispatcher to create one worker thread
Packit 13e616
*		per CPU in the system.  When the Dispatcher is created with
Packit 13e616
*		only one thread, the Dispatcher guarantees to deliver posted
Packit 13e616
*		messages in order.  When the Dispatcher is created with more
Packit 13e616
*		than one thread, messages may be delivered out of order.
Packit 13e616
*
Packit 13e616
*	name
Packit 13e616
*		[in] Name to associate with the threads.  The name may be up to 16
Packit 13e616
*		characters, including a terminating null character.  All threads
Packit 13e616
*		created in the Dispatcher have the same name.
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	CL_SUCCESS if the operation is successful.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Dispatcher, cl_disp_destroy, cl_disp_register, cl_disp_unregister,
Packit 13e616
*	cl_disp_post
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* Component Library: Dispatcher/cl_disp_shutdown
Packit 13e616
* NAME
Packit 13e616
*	cl_disp_shutdown
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	This function shutdown a Dispatcher object. So it unreg all messages and
Packit 13e616
*  clears the fifo and waits for the threads to exit
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
void cl_disp_shutdown(IN cl_dispatcher_t * const p_disp);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	p_disp
Packit 13e616
*		[in] Pointer to a Dispatcher.
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	This function does not return a value.
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*	This function does not returns until all worker threads
Packit 13e616
*	have exited client callback functions and been successfully
Packit 13e616
*	shutdowned.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Dispatcher, cl_disp_construct, cl_disp_init
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* Component Library: Dispatcher/cl_disp_destroy
Packit 13e616
* NAME
Packit 13e616
*	cl_disp_destroy
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	This function destroys a Dispatcher object.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
void cl_disp_destroy(IN cl_dispatcher_t * const p_disp);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	p_disp
Packit 13e616
*		[in] Pointer to a Dispatcher.
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	This function does not return a value.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Dispatcher, cl_disp_construct, cl_disp_init
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* Component Library: Dispatcher/cl_disp_register
Packit 13e616
* NAME
Packit 13e616
*	cl_disp_register
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	This function registers a client with a Dispatcher object.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
cl_disp_reg_handle_t
Packit 13e616
cl_disp_register(IN cl_dispatcher_t * const p_disp,
Packit 13e616
		 IN const cl_disp_msgid_t msg_id,
Packit 13e616
		 IN cl_pfn_msgrcv_cb_t pfn_callback OPTIONAL,
Packit 13e616
		 IN const void *const context);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	p_disp
Packit 13e616
*		[in] Pointer to a Dispatcher.
Packit 13e616
*
Packit 13e616
*	msg_id
Packit 13e616
*		[in] Numberic message ID for which the client is registering.
Packit 13e616
*		If the client does not wish to receive any messages,
Packit 13e616
*		(a send-only client) then the caller should set this value
Packit 13e616
*		to CL_DISP_MSGID_NONE.  For efficiency, numeric message msg_id
Packit 13e616
*		values should start with 0 and should be contiguous, or nearly so.
Packit 13e616
*
Packit 13e616
*	pfn_callback
Packit 13e616
*		[in] Message receive callback.  The Dispatcher calls this
Packit 13e616
*		function after receiving a posted message with the
Packit 13e616
*		appropriate message msg_id value.  Send-only clients may specify
Packit 13e616
*		NULL for this value.
Packit 13e616
*
Packit 13e616
*	context
Packit 13e616
*		[in] Client context value passed to the cl_pfn_msgrcv_cb_t
Packit 13e616
*		function.
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	On success a Dispatcher registration handle.
Packit 13e616
*	CL_CL_DISP_INVALID_HANDLE otherwise.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Dispatcher, cl_disp_unregister, cl_disp_post
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* Component Library: Dispatcher/cl_disp_unregister
Packit 13e616
* NAME
Packit 13e616
*	cl_disp_unregister
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	This function unregisters a client from a Dispatcher.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
void cl_disp_unregister(IN const cl_disp_reg_handle_t handle);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	handle
Packit 13e616
*		[in] cl_disp_reg_handle_t value return by cl_disp_register.
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	This function does not return a value.
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*	This function will not return until worker threads have exited
Packit 13e616
*	the callback functions for this client.  Do not invoke this
Packit 13e616
*	function from a callback.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Dispatcher, cl_disp_register
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* Component Library: Dispatcher/cl_disp_post
Packit 13e616
* NAME
Packit 13e616
*	cl_disp_post
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	This function posts a message to a Dispatcher object.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
cl_status_t
Packit 13e616
cl_disp_post(IN const cl_disp_reg_handle_t handle,
Packit 13e616
	     IN const cl_disp_msgid_t msg_id,
Packit 13e616
	     IN const void *const p_data,
Packit 13e616
	     IN cl_pfn_msgdone_cb_t pfn_callback OPTIONAL,
Packit 13e616
	     IN const void *const context);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*	handle
Packit 13e616
*		[in] cl_disp_reg_handle_t value return by cl_disp_register.
Packit 13e616
*
Packit 13e616
*	msg_id
Packit 13e616
*		[in] Numeric message msg_id value associated with this message.
Packit 13e616
*
Packit 13e616
*	p_data
Packit 13e616
*		[in] Data payload for this message.
Packit 13e616
*
Packit 13e616
*	pfn_callback
Packit 13e616
*		[in] Pointer to a cl_pfn_msgdone_cb_t function.
Packit 13e616
*		The Dispatcher calls this function after the message has been
Packit 13e616
*		processed by the recipient.
Packit 13e616
*		The caller may pass NULL for this value, which indicates no
Packit 13e616
*		message done callback is necessary.
Packit 13e616
*
Packit 13e616
*	context
Packit 13e616
*		[in] Client context value passed to the cl_pfn_msgdone_cb_t
Packit 13e616
*		function.
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	CL_SUCCESS if the message was successfully queued in the Dispatcher.
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*	The caller must not modify the memory pointed to by p_data until
Packit 13e616
*	the Dispatcher call the pfn_callback function.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Dispatcher
Packit 13e616
*********/
Packit 13e616
Packit 13e616
/****f* Component Library: Dispatcher/cl_disp_get_queue_status
Packit 13e616
* NAME
Packit 13e616
*	cl_disp_get_queue_status
Packit 13e616
*
Packit 13e616
* DESCRIPTION
Packit 13e616
*	This function gets queue status of a Dispatcher object.
Packit 13e616
*
Packit 13e616
* SYNOPSIS
Packit 13e616
*/
Packit 13e616
void
Packit 13e616
cl_disp_get_queue_status(IN const cl_disp_reg_handle_t handle,
Packit 13e616
			 OUT uint32_t * p_num_queued_msgs,
Packit 13e616
			 OUT uint64_t * p_last_msg_queue_time_ms);
Packit 13e616
/*
Packit 13e616
* PARAMETERS
Packit 13e616
*   handle
Packit 13e616
*     [in] cl_disp_reg_handle_t value return by cl_disp_register.
Packit 13e616
*
Packit 13e616
*   p_num_queued_msgs
Packit 13e616
*     [out] number of messages in the queue
Packit 13e616
*
Packit 13e616
*   p_last_msg_queue_time_ms
Packit 13e616
*     [out] pointer to a variable to hold the time the last popped up message
Packit 13e616
*           spent in the queue
Packit 13e616
*
Packit 13e616
* RETURN VALUE
Packit 13e616
*	Thr time the last popped up message stayed in the queue, in msec
Packit 13e616
*
Packit 13e616
* NOTES
Packit 13e616
*	Extarnel Locking is not required.
Packit 13e616
*
Packit 13e616
* SEE ALSO
Packit 13e616
*	Dispatcher
Packit 13e616
*********/
Packit 13e616
Packit 13e616
END_C_DECLS
Packit 13e616
#endif				/* !defined(_CL_DISPATCHER_H_) */