1 karl 1.10 //%2006////////////////////////////////////////////////////////////////////////
|
2 schuur 1.1 //
|
3 karl 1.7 // Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development
4 // Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems.
5 // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L.P.;
|
6 schuur 1.1 // IBM Corp.; EMC Corporation, The Open Group.
|
7 karl 1.7 // Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.;
8 // IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group.
|
9 karl 1.8 // Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.;
10 // EMC Corporation; VERITAS Software Corporation; The Open Group.
|
11 karl 1.10 // Copyright (c) 2006 Hewlett-Packard Development Company, L.P.; IBM Corp.;
12 // EMC Corporation; Symantec Corporation; The Open Group.
|
13 schuur 1.1 //
14 // Permission is hereby granted, free of charge, to any person obtaining a copy
15 // of this software and associated documentation files (the "Software"), to
16 // deal in the Software without restriction, including without limitation the
17 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
18 // sell copies of the Software, and to permit persons to whom the Software is
19 // furnished to do so, subject to the following conditions:
|
20 karl 1.7 //
|
21 schuur 1.1 // THE ABOVE COPYRIGHT NOTICE AND THIS PERMISSION NOTICE SHALL BE INCLUDED IN
22 // ALL COPIES OR SUBSTANTIAL PORTIONS OF THE SOFTWARE. THE SOFTWARE IS PROVIDED
23 // "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
24 // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
25 // PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
26 // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
27 // ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 //
30 //==============================================================================
31 //
32 // Author: Adrian Schuur, schuur@de.ibm.com
33 //
34 // Modified By:
35 //
36 //%/////////////////////////////////////////////////////////////////////////////
37
|
38 schuur 1.4 #include "CMPI_Version.h"
|
39 schuur 1.2
|
40 schuur 1.1 #include "CMPI_Object.h"
41
|
42 schuur 1.3 #ifndef PEGASUS_PLATFORM_WIN32_IX86_MSVC
|
43 schuur 1.1 #include <pthread.h>
|
44 schuur 1.3 #endif
|
45 schuur 1.1 #include <limits.h>
46
47
48 PEGASUS_USING_STD;
49 PEGASUS_NAMESPACE_BEGIN
50
|
51 mike 1.11 TSDKeyType CMPI_ThreadContext::contextKey;
|
52 schuur 1.3 int CMPI_ThreadContext::context_key_once=1;
|
53 schuur 1.1
54 void CMPI_ThreadContext::context_key_alloc()
55 {
|
56 mike 1.11 TSDKey::create(&contextKey);
|
57 schuur 1.1 }
58
|
59 mike 1.11 TSDKeyType CMPI_ThreadContext::getContextKey()
|
60 schuur 1.1 {
|
61 schuur 1.3 if (context_key_once) {
62 context_key_alloc();
63 context_key_once=0;
64 }
|
65 schuur 1.1 return contextKey;
66 }
67
68 void CMPI_ThreadContext::add(CMPI_Object *o) {
69 ENQ_TOP_LIST(o,CIMfirst,CIMlast,next,prev);
70 }
71
72 void CMPI_ThreadContext::addObject(CMPI_Object* o) {
73 CMPI_ThreadContext* ctx=getThreadContext();
74 ctx->add(o);
75 }
76
77 void CMPI_ThreadContext::remove(CMPI_Object *o) {
|
78 schuur 1.5 if (reinterpret_cast<long>(o->next)!=-1) {
79 DEQ_FROM_LIST(o,CIMfirst,CIMlast,next,prev);
80 o->next=reinterpret_cast<CMPI_Object*>((void*)-1l);
81 }
|
82 schuur 1.1 }
83
84 void CMPI_ThreadContext::remObject(CMPI_Object* o) {
85 CMPI_ThreadContext* ctx=getThreadContext();
86 ctx->remove(o);
87 }
88
89 CMPI_ThreadContext* CMPI_ThreadContext::getThreadContext() {
|
90 mike 1.11 TSDKeyType k=getContextKey();
|
91 schuur 1.1 #ifndef PEGASUS_PLATFORM_ZOS_ZSERIES_IBM
|
92 mike 1.11 return (CMPI_ThreadContext*)TSDKey::get_thread_specific(k);
|
93 schuur 1.1 #else
94 CMPI_ThreadContext* tCtx=NULL;
95 pthread_getspecific(k,(void**)&tCtx);
96 return tCtx;
97 #endif
98 }
99
|
100 konrad.r 1.9 const CMPIBroker* CMPI_ThreadContext::getBroker() {
|
101 konrad.r 1.6 //return getThreadContext()->broker;
102 CMPI_ThreadContext *ctx = getThreadContext();
103 if (ctx)
104 return ctx->broker;
105 return 0;
|
106 schuur 1.1 }
107
|
108 konrad.r 1.9 const CMPIContext* CMPI_ThreadContext::getContext() {
|
109 schuur 1.1 return getThreadContext()->context;
110 }
111
|
112 konrad.r 1.9 CMPI_ThreadContext::CMPI_ThreadContext(const CMPIBroker *mb, const CMPIContext *ctx ) {
|
113 schuur 1.1 CIMfirst=CIMlast=NULL;
114 broker=mb;
115 context=ctx;
|
116 mike 1.11 TSDKeyType k=getContextKey();
|
117 schuur 1.1 #ifndef PEGASUS_PLATFORM_ZOS_ZSERIES_IBM
|
118 mike 1.11 prev=(CMPI_ThreadContext*)TSDKey::get_thread_specific(k);
|
119 schuur 1.1 #else
120 pthread_getspecific(k,(void**)&prev);
121 #endif
|
122 mike 1.11 TSDKey::set_thread_specific(k,this);
|
123 schuur 1.1 return;
124 }
125
126 CMPI_ThreadContext::~CMPI_ThreadContext() {
127 for (CMPI_Object *nxt,*cur=CIMfirst; cur; cur=nxt) {
128 nxt=cur->next;
129 ((CMPIInstance*)cur)->ft->release((CMPIInstance*)cur);
130 }
131
|
132 mike 1.11 TSDKeyType k=getContextKey();
133 TSDKey::set_thread_specific(k,prev);
|
134 schuur 1.1 }
135
136
137 PEGASUS_NAMESPACE_END
|