~ubuntu-branches/debian/jessie/ugene/jessie

« back to all changes in this revision

Viewing changes to src/plugins/external_tool_support/src/TaskLocalStorage.cpp

  • Committer: Package Import Robot
  • Author(s): Steffen Moeller
  • Date: 2011-11-02 13:29:07 UTC
  • mfrom: (1.2.1) (3.1.11 natty)
  • Revision ID: package-import@ubuntu.com-20111102132907-o34gwnt0uj5g6hen
Tags: 1.9.8+repack-1
* First release to Debian
  - added README.Debian
  - increased policy version to 3.9.2
  - added URLs for version control system
* Added debug package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * UGENE - Integrated Bioinformatics Tools.
 
3
 * Copyright (C) 2008-2011 UniPro <ugene@unipro.ru>
 
4
 * http://ugene.unipro.ru
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU General Public License
 
8
 * as published by the Free Software Foundation; either version 2
 
9
 * of the License, or (at your option) any later version.
 
10
 *
 
11
 * This program is distributed in the hope that it will be useful,
 
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
14
 * GNU General Public License for more details.
 
15
 *
 
16
 * You should have received a copy of the GNU General Public License
 
17
 * along with this program; if not, write to the Free Software
 
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 
19
 * MA 02110-1301, USA.
 
20
 */
 
21
 
 
22
#include "TaskLocalStorage.h"
 
23
#include <assert.h>
 
24
 
 
25
class ETSContext *getETSContext() {
 
26
    return U2::TaskLocalData::current();
 
27
}
 
28
int getETSWorkerID() {
 
29
    return U2::TaskLocalData::currentWorkerID();
 
30
}
 
31
 
 
32
namespace U2 {
 
33
 
 
34
QThreadStorage<ETSContextTLSRef*> TaskLocalData::tls;
 
35
 
 
36
class ETSContext* TaskLocalData::current(){
 
37
    ETSContextTLSRef* ref = tls.localData();
 
38
    if (ref!=NULL) {
 
39
        assert(ref->ctx!=NULL);
 
40
        return ref->ctx;
 
41
    }
 
42
    assert(0);
 
43
    return NULL;
 
44
}
 
45
 
 
46
unsigned TaskLocalData::currentWorkerID() {
 
47
    ETSContextTLSRef* ref = tls.localData();
 
48
    if (ref!=NULL) {
 
49
        return ref->workerID;
 
50
    }
 
51
    assert(0);
 
52
    return -1;
 
53
 
 
54
}
 
55
 
 
56
void TaskLocalData::bindToETSTLSContext(ETSContext *ctx, int workerID) {
 
57
    assert(ctx!=NULL);
 
58
    assert(!tls.hasLocalData());
 
59
    tls.setLocalData(new ETSContextTLSRef(ctx, workerID));
 
60
}
 
61
 
 
62
void TaskLocalData::detachETSTLSContext() {
 
63
    ETSContextTLSRef* ref = tls.localData();
 
64
    assert(ref!=NULL && ref->ctx!=NULL);
 
65
    ref->ctx = NULL;
 
66
    tls.setLocalData(NULL);
 
67
}
 
68
 
 
69
 
 
70
}//namespace
 
71