NCBI C++ ToolKit
nw_aligner_threads.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: nw_aligner_threads.cpp 33815 2007-05-04 17:18:18Z kazimird $
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  * Authors: Yuri Kapustin
27  *
28  * File Description: CNWAligner thread classes implementation
29  *
30  * ===========================================================================
31  *
32  */
33 
34 #include <ncbi_pch.hpp>
35 #include "nw_aligner_threads.hpp"
36 
37 
39 
40 unsigned int g_nwnw_thread_count = 1;
41 
42 DEFINE_STATIC_FAST_MUTEX(thread_count_mutex_nw);
43 
44 bool NW_RequestNewThread(const unsigned int max_threads)
45 {
46  CFastMutexGuard guard(thread_count_mutex_nw);
47  if(g_nwnw_thread_count < max_threads) {
49  return true;
50  }
51  else
52  return false;
53 }
54 
56 {
57  m_exception.reset(0);
58 
59  try {
61  }
62 
63  catch(CException& e) {
64 
65  m_exception.reset(new CException(e));
66  }
67 
68  catch(...) {
69 
72  "Unregistered exception caught from "
73  "CNWAligner::x_Align()"));
74  }
75 
76  return m_exception.get();
77 }
78 
79 
81 {
82  CFastMutexGuard guard(thread_count_mutex_nw);
84 }
85 
virtual void OnExit()
Override this to execute finalization code.
unique_ptr< CException > m_exception
CNWAligner::SAlignInOut * m_data
virtual void * Main()
Derived (user-created) class must provide a real thread function.
virtual TScore x_Align(SAlignInOut *data)
Definition: nw_aligner.cpp:229
#define DIAG_COMPILE_INFO
Make compile time diagnostic information object to use in CNcbiDiag and CException.
Definition: ncbidiag.hpp:170
@ eUnknown
Unknown exception.
Definition: ncbiexpt.hpp:887
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
unsigned int g_nwnw_thread_count
DEFINE_STATIC_FAST_MUTEX(thread_count_mutex_nw)
bool NW_RequestNewThread(const unsigned int max_threads)
Modified on Wed Sep 04 15:05:40 2024 by modify_doxy.py rev. 669887