NCBI C Toolkit Cross Reference

C/algo/blast/api/blast_mtlock.c


  1 /*  $Id: blast_mtlock.c,v 1.6 2006/05/24 21:17:50 camacho Exp $
  2  * ===========================================================================
  3  *
  4  *                            PUBLIC DOMAIN NOTICE
  5  *               National Center for Biotechnology Information
  6  *
  7  *  This software/database is a "United States Government Work" under the
  8  *  terms of the United States Copyright Act.  It was written as part of
  9  *  the author's official duties as a United States Government employee and
 10  *  thus cannot be copyrighted.  This software/database is freely available
 11  *  to the public for use. The National Library of Medicine and the U.S.
 12  *  Government have not placed any restriction on its use or reproduction.
 13  *
 14  *  Although all reasonable efforts have been taken to ensure the accuracy
 15  *  and reliability of the software and data, the NLM and the U.S.
 16  *  Government do not and cannot warrant the performance or results that
 17  *  may be obtained by using this software or data. The NLM and the U.S.
 18  *  Government disclaim all warranties, express or implied, including
 19  *  warranties of performance, merchantability or fitness for any particular
 20  *  purpose.
 21  *
 22  *  Please cite the author in any work or product based on this material.
 23  *
 24  * ===========================================================================
 25  *
 26  * Author:  Ilya Dondoshansky
 27  *
 28  */
 29 
 30 /** @file blast_mtlock.c
 31  * Initialization for the mutex locking interface. 
 32  */
 33 
 34 #ifndef SKIP_DOXYGEN_PROCESSING
 35 static char const rcsid[] = 
 36     "$Id: blast_mtlock.c,v 1.6 2006/05/24 21:17:50 camacho Exp $";
 37 #endif /* SKIP_DOXYGEN_PROCESSING */
 38 
 39 #include <ncbithr.h>
 40 #include <algo/blast/api/blast_mtlock.h>
 41 #include <algo/blast/core/blast_def.h>
 42 
 43 /** @addtogroup CToolkitAlgoBlast
 44  *
 45  * @{
 46  */
 47 
 48 /** Mutex lock handler for saving BLAST results. 
 49  * @param user_data Pointer to the mutex [in]
 50  * @param how What to do with the mutex? [in]
 51  */
 52 static int CollectorLockHandler(void* user_data, EMT_Lock how)
 53 {
 54    int result = 0;
 55    
 56    switch ( how ) {
 57    case eMT_Lock:
 58       result = NlmMutexLock((TNlmMutex)user_data) == 0;
 59       break;
 60    case eMT_Unlock:
 61       result = NlmMutexUnlock((TNlmMutex)user_data) == 0;
 62       break;
 63    default:
 64       break;
 65    }
 66    
 67    return result;
 68 }
 69 
 70 /** Mutex lock clean up handler.
 71  * @param user_data Pointer to the mutex [in]
 72  */
 73 static void CollectorLockCleanup(void* user_data)
 74 {
 75    NlmMutexDestroy((TNlmMutex)user_data);
 76 }
 77 
 78 MT_LOCK Blast_MT_LOCKInit()
 79 {
 80    MT_LOCK lock;
 81    TNlmMutex results_mutex = NULL;
 82    results_mutex = NlmMutexInit(&results_mutex);
 83    lock = MT_LOCK_Create((void*)results_mutex, CollectorLockHandler, 
 84                      CollectorLockCleanup);
 85    return lock;
 86 }
 87 
 88 /* @} */
 89 
 90 

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.