Beispiel #1
0
/*	===== tls_term =================================================================
	PRIVATE. Terminate TLS management.
	Note: When its called, you should be sure that there is no more thread to call
		TLS services.
	================================================================================	*/
status_t tls_term ()
	{
	status_t exit_value ;
	int i ;

	if (!gm_initOk) return B_NO_ERROR ;

	//	Signal to monitoring thread that it must end, and waits for it.
	release_sem (gm_signalExit) ;
	wait_for_thread (gm_monitor, &exit_value) ;
	//	Free monitor references.
	delete_sem (gm_signalExit) ; 
	gm_signalExit = 0 ;
	gm_monitor = 0 ;

	//	Remove entry and exit procs.
	while (gm_entry_proc_list && (B_NO_ERROR == tls_remove_entry_exit (PROC_ENTRY, 
						gm_entry_proc_list->proc, gm_entry_proc_list->param))) ;
	while (gm_exit_proc_list &&  (B_NO_ERROR == tls_remove_entry_exit (PROC_EXIT, 
						gm_exit_proc_list->proc, gm_exit_proc_list->param))) ;

	//	Acquire resources to be released. 
	if (gm_mutex_entries)		tls_index_mutex_p () ;
	if (gm_mutex_indexs)		tls_entries_mutex_p () ;
	if (gm_mutex_entry_exit)	tls_entry_exit_mutex_p () ;

	//	Free resources. 
	delete_sem (gm_mutex_entries) ; 
	gm_mutex_entries = 0 ;
	gm_mutex_entries_val = 1 ;
	for (i=0 ; i<THREAD_ENTRIES_RECENT_COUNT ; i++) gm_recent[i] = NULL ;

	delete_sem (gm_mutex_indexs) ;
	gm_mutex_indexs = 0 ;
	gm_mutex_indexs_val = 1 ;

	delete_sem (gm_mutex_entry_exit) ;
	gm_mutex_entry_exit = 0 ;
	gm_mutex_entry_exit_val = 1 ;

	//	Note: memory is not freed, and counters are not reseted (can be reused as is).
	if (gm_indexs) memset (gm_indexs, 0, sizeof(bool)*gm_indexs_allocated_count) ;

	gm_initOk = false ;

	return B_NO_ERROR ;
	}
Beispiel #2
0
/*	===== tls_remove_exit_proc =====================================================
	PUBLIC. 
	================================================================================	*/
status_t tls_remove_exit_proc (tls_proc_t proc, int param) 
	{
	return tls_remove_entry_exit (PROC_EXIT, proc, param) ;
	}