2
* UGENE - Integrated Bioinformatics Tools.
3
* Copyright (C) 2008-2011 UniPro <ugene@unipro.ru>
4
* http://ugene.unipro.ru
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.
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.
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,
22
#include "TaskLocalStorage.h"
25
class ETSContext *getETSContext() {
26
return U2::TaskLocalData::current();
28
int getETSWorkerID() {
29
return U2::TaskLocalData::currentWorkerID();
34
QThreadStorage<ETSContextTLSRef*> TaskLocalData::tls;
36
class ETSContext* TaskLocalData::current(){
37
ETSContextTLSRef* ref = tls.localData();
39
assert(ref->ctx!=NULL);
46
unsigned TaskLocalData::currentWorkerID() {
47
ETSContextTLSRef* ref = tls.localData();
56
void TaskLocalData::bindToETSTLSContext(ETSContext *ctx, int workerID) {
58
assert(!tls.hasLocalData());
59
tls.setLocalData(new ETSContextTLSRef(ctx, workerID));
62
void TaskLocalData::detachETSTLSContext() {
63
ETSContextTLSRef* ref = tls.localData();
64
assert(ref!=NULL && ref->ctx!=NULL);
66
tls.setLocalData(NULL);