~ubuntu-branches/ubuntu/vivid/deal.ii/vivid

« back to all changes in this revision

Viewing changes to contrib/tbb/tbb22_20090809oss/include/tbb/task_scheduler_init.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam C. Powell, IV, Adam C. Powell, IV, Denis Barbier
  • Date: 2010-07-29 13:47:01 UTC
  • mfrom: (3.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20100729134701-akb8jb3stwge8tcm
Tags: 6.3.1-1
[ Adam C. Powell, IV ]
* Changed to source format 3.0 (quilt).
* Changed maintainer to debian-science with Adam Powell as uploader.
* Added source lintian overrides about Adam Powell's name.
* Added Vcs info on git repository.
* Bumped Standards-Version.
* Changed stamp-patch to patch target and fixed its application criterion.
* Moved make_dependencies and expand_instantiations to a versioned directory
  to avoid shlib package conflicts.

[ Denis Barbier ]
* New upstream release (closes: #562332).
  + Added libtbb support.
  + Forward-ported all patches.
* Updates for new PETSc version, including workaround for different versions
  of petsc and slepc.
* Add debian/watch.
* Update to debhelper 7.
* Added pdebuild patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
    Copyright 2005-2009 Intel Corporation.  All Rights Reserved.
 
3
 
 
4
    This file is part of Threading Building Blocks.
 
5
 
 
6
    Threading Building Blocks is free software; you can redistribute it
 
7
    and/or modify it under the terms of the GNU General Public License
 
8
    version 2 as published by the Free Software Foundation.
 
9
 
 
10
    Threading Building Blocks is distributed in the hope that it will be
 
11
    useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 
12
    of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
    GNU General Public License for more details.
 
14
 
 
15
    You should have received a copy of the GNU General Public License
 
16
    along with Threading Building Blocks; if not, write to the Free Software
 
17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 
 
19
    As a special exception, you may use this file as part of a free software
 
20
    library without restriction.  Specifically, if other files instantiate
 
21
    templates or use macros or inline functions from this file, or you compile
 
22
    this file and link it with other files to produce an executable, this
 
23
    file does not by itself cause the resulting executable to be covered by
 
24
    the GNU General Public License.  This exception does not however
 
25
    invalidate any other reasons why the executable file might be covered by
 
26
    the GNU General Public License.
 
27
*/
 
28
 
 
29
#ifndef __TBB_task_scheduler_init_H
 
30
#define __TBB_task_scheduler_init_H
 
31
 
 
32
#include "tbb_stddef.h"
 
33
 
 
34
namespace tbb {
 
35
 
 
36
typedef std::size_t stack_size_type;
 
37
 
 
38
//! @cond INTERNAL
 
39
namespace internal {
 
40
    //! Internal to library. Should not be used by clients.
 
41
    /** @ingroup task_scheduling */
 
42
    class scheduler;
 
43
} // namespace internal
 
44
//! @endcond
 
45
 
 
46
//! Class representing reference to tbb scheduler.
 
47
/** A thread must construct a task_scheduler_init, and keep it alive,
 
48
    during the time that it uses the services of class task.
 
49
    @ingroup task_scheduling */
 
50
class task_scheduler_init: internal::no_copy {
 
51
    /** NULL if not currently initialized. */
 
52
    internal::scheduler* my_scheduler;
 
53
public:
 
54
 
 
55
    //! Typedef for number of threads that is automatic.
 
56
    static const int automatic = -1;
 
57
 
 
58
    //! Argument to initialize() or constructor that causes initialization to be deferred.
 
59
    static const int deferred = -2;
 
60
 
 
61
    //! Ensure that scheduler exists for this thread
 
62
    /** A value of -1 lets tbb decide on the number of threads, which is typically 
 
63
        the number of hardware threads. For production code, the default value of -1 
 
64
        should be used, particularly if the client code is mixed with third party clients 
 
65
        that might also use tbb.
 
66
 
 
67
        The number_of_threads is ignored if any other task_scheduler_inits 
 
68
        currently exist.  A thread may construct multiple task_scheduler_inits.  
 
69
        Doing so does no harm because the underlying scheduler is reference counted. */
 
70
    void __TBB_EXPORTED_METHOD initialize( int number_of_threads=automatic );
 
71
 
 
72
    //! The overloaded method with stack size parameter
 
73
    /** Overloading is necessary to preserve ABI compatibility */
 
74
    void __TBB_EXPORTED_METHOD initialize( int number_of_threads, stack_size_type thread_stack_size );
 
75
 
 
76
    //! Inverse of method initialize.
 
77
    void __TBB_EXPORTED_METHOD terminate();
 
78
 
 
79
    //! Shorthand for default constructor followed by call to intialize(number_of_threads).
 
80
    task_scheduler_init( int number_of_threads=automatic, stack_size_type thread_stack_size=0 ) : my_scheduler(NULL)  {
 
81
        initialize( number_of_threads, thread_stack_size );
 
82
    }
 
83
 
 
84
    //! Destroy scheduler for this thread if thread has no other live task_scheduler_inits.
 
85
    ~task_scheduler_init() {
 
86
        if( my_scheduler ) 
 
87
            terminate();
 
88
        internal::poison_pointer( my_scheduler );
 
89
    }
 
90
    //! Returns the number of threads tbb scheduler would create if initialized by default.
 
91
    /** Result returned by this method does not depend on whether the scheduler 
 
92
        has already been initialized.
 
93
        
 
94
        Because tbb 2.0 does not support blocking tasks yet, you may use this method
 
95
        to boost the number of threads in the tbb's internal pool, if your tasks are 
 
96
        doing I/O operations. The optimal number of additional threads depends on how
 
97
        much time your tasks spend in the blocked state. */
 
98
    static int __TBB_EXPORTED_FUNC default_num_threads ();
 
99
 
 
100
    //! Returns true if scheduler is active (initialized); false otherwise
 
101
    bool is_active() const { return my_scheduler != NULL; }
 
102
};
 
103
 
 
104
} // namespace tbb
 
105
 
 
106
#endif /* __TBB_task_scheduler_init_H */