/usr/include/ace/TSS_T.cpp is in libace-dev 6.0.3+dfsg-0.1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 | // $Id: TSS_T.cpp 93792 2011-04-07 11:48:50Z mcorino $
#ifndef ACE_TSS_T_CPP
#define ACE_TSS_T_CPP
#include "ace/TSS_T.h"
#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */
#if !defined (__ACE_INLINE__)
#include "ace/TSS_T.inl"
#endif /* __ACE_INLINE__ */
#include "ace/Thread.h"
#include "ace/Log_Msg.h"
#include "ace/Guard_T.h"
#include "ace/OS_NS_stdio.h"
#if defined (ACE_HAS_THR_C_DEST)
# include "ace/TSS_Adapter.h"
#endif /* ACE_HAS_THR_C_DEST */
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_ALLOC_HOOK_DEFINE(ACE_TSS)
#if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))
# if defined (ACE_HAS_THR_C_DEST)
extern "C" ACE_Export void ACE_TSS_C_cleanup (void *);
# endif /* ACE_HAS_THR_C_DEST */
#endif /* defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) */
template <class TYPE>
ACE_TSS<TYPE>::~ACE_TSS (void)
{
#if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))
if (this->once_)
{
# if defined (ACE_HAS_THR_C_DEST)
ACE_TSS_Adapter *tss_adapter = this->ts_value ();
this->ts_value (0);
ACE_TSS_C_cleanup (tss_adapter);
# else
TYPE *ts_obj = this->ts_value ();
this->ts_value (0);
ACE_TSS<TYPE>::cleanup (ts_obj);
# endif /* ACE_HAS_THR_C_DEST */
ACE_OS::thr_key_detach (this->key_);
ACE_OS::thr_keyfree (this->key_);
}
#else // defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))
// We own it, we need to delete it.
delete type_;
#endif // defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))
}
template <class TYPE> TYPE *
ACE_TSS<TYPE>::operator-> () const
{
return this->ts_get ();
}
template <class TYPE>
ACE_TSS<TYPE>::operator TYPE *(void) const
{
return this->ts_get ();
}
template <class TYPE> TYPE *
ACE_TSS<TYPE>::make_TSS_TYPE (void) const
{
TYPE *temp = 0;
ACE_NEW_RETURN (temp,
TYPE,
0);
return temp;
}
template <class TYPE> void
ACE_TSS<TYPE>::dump (void) const
{
#if defined (ACE_HAS_DUMP)
#if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))
ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
this->keylock_.dump ();
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("key_ = %d\n"), this->key_));
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\nonce_ = %d\n"), this->once_));
ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
#endif /* defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) */
#endif /* ACE_HAS_DUMP */
}
#if defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))
template <class TYPE> void
ACE_TSS<TYPE>::cleanup (void *ptr)
{
// Cast this to the concrete TYPE * so the destructor gets called.
delete (TYPE *) ptr;
}
template <class TYPE> int
ACE_TSS<TYPE>::ts_init (void)
{
// Ensure that we are serialized!
ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->keylock_, 0);
// Use the Double-Check pattern to make sure we only create the key
// once!
if (!this->once_)
{
if (ACE_Thread::keycreate (&this->key_,
#if defined (ACE_HAS_THR_C_DEST)
&ACE_TSS_C_cleanup
#else
&ACE_TSS<TYPE>::cleanup
#endif /* ACE_HAS_THR_C_DEST */
) != 0)
return -1; // Major problems, this should *never* happen!
else
{
// This *must* come last to avoid race conditions!
this->once_ = true;
return 0;
}
}
return 0;
}
template <class TYPE>
ACE_TSS<TYPE>::ACE_TSS (TYPE *ts_obj)
: once_ (false),
key_ (ACE_OS::NULL_key)
{
// If caller has passed us a non-NULL TYPE *, then we'll just use
// this to initialize the thread-specific value. Thus, subsequent
// calls to operator->() will return this value. This is useful
// since it enables us to assign objects to thread-specific data
// that have arbitrarily complex constructors!
if (ts_obj != 0)
{
if (this->ts_init () == -1)
{
// Save/restore errno.
ACE_Errno_Guard error (errno);
// What should we do if this call fails?!
#if defined (ACE_HAS_WINCE)
::MessageBox (0,
ACE_TEXT ("ACE_Thread::keycreate() failed!"),
ACE_TEXT ("ACE_TSS::ACE_TSS"),
MB_OK);
#else
ACE_OS::fprintf (stderr,
"ACE_Thread::keycreate() failed!");
#endif /* ACE_HAS_WINCE */
return;
}
#if defined (ACE_HAS_THR_C_DEST)
// Encapsulate a ts_obj and it's destructor in an
// ACE_TSS_Adapter.
ACE_TSS_Adapter *tss_adapter = 0;
ACE_NEW (tss_adapter,
ACE_TSS_Adapter ((void *) ts_obj,
ACE_TSS<TYPE>::cleanup));
// Put the adapter in thread specific storage
if (this->ts_value (tss_adapter) == -1)
{
delete tss_adapter;
}
#else
this->ts_value (ts_obj);
#endif /* ACE_HAS_THR_C_DEST */
}
}
template <class TYPE> TYPE *
ACE_TSS<TYPE>::ts_get (void) const
{
if (!this->once_)
{
// Create and initialize thread-specific ts_obj.
if (const_cast< ACE_TSS < TYPE > * >(this)->ts_init () == -1)
// Seriously wrong..
return 0;
}
TYPE *ts_obj = 0;
#if defined (ACE_HAS_THR_C_DEST)
ACE_TSS_Adapter *tss_adapter = this->ts_value ();
ACE_TSS_Adapter *fake_tss_adapter = 0;
// If tss_adapter is not 0 but its ts_obj_ is 0 then we still need to create
// a proper ts_obj. That's the intent of this member function.
if (tss_adapter != 0 && tss_adapter->ts_obj_ == 0)
{
fake_tss_adapter = tss_adapter;
tss_adapter = 0;
}
// Check to see if this is the first time in for this thread.
if (tss_adapter == 0)
#else
ts_obj = this->ts_value ();
// Check to see if this is the first time in for this thread.
if (ts_obj == 0)
#endif /* ACE_HAS_THR_C_DEST */
{
// Allocate memory off the heap and store it in a pointer in
// thread-specific storage (on the stack...).
ts_obj = this->make_TSS_TYPE ();
if (ts_obj == 0)
return 0;
#if defined (ACE_HAS_THR_C_DEST)
// Encapsulate a ts_obj and it's destructor in an
// ACE_TSS_Adapter.
ACE_NEW_RETURN (tss_adapter,
ACE_TSS_Adapter (ts_obj,
ACE_TSS<TYPE>::cleanup), 0);
// Put the adapter in thread specific storage
if (this->ts_value (tss_adapter) == -1)
{
delete tss_adapter;
delete ts_obj;
return 0; // Major problems, this should *never* happen!
}
#else
// Store the dynamically allocated pointer in thread-specific
// storage.
if (this->ts_value (ts_obj) == -1)
{
delete ts_obj;
return 0; // Major problems, this should *never* happen!
}
#endif /* ACE_HAS_THR_C_DEST */
}
#if defined (ACE_HAS_THR_C_DEST)
// Delete the adapter that didn't actually have a real ts_obj.
delete fake_tss_adapter;
// Return the underlying ts object.
return static_cast <TYPE *> (tss_adapter->ts_obj_);
#else
return ts_obj;
#endif /* ACE_HAS_THR_C_DEST */
}
// Get the thread-specific object for the key associated with this
// object. Returns 0 if the ts_obj has never been initialized,
// otherwise returns a pointer to the ts_obj.
template <class TYPE> TYPE *
ACE_TSS<TYPE>::ts_object (void) const
{
if (!this->once_) // Return 0 if we've never been initialized.
return 0;
TYPE *ts_obj = 0;
#if defined (ACE_HAS_THR_C_DEST)
ACE_TSS_Adapter *tss_adapter = this->ts_value ();
if (tss_adapter != 0)
{
// Extract the real TS object.
ts_obj = static_cast <TYPE *> (tss_adapter->ts_obj_);
}
#else
ts_obj = this->ts_value ();
#endif /* ACE_HAS_THR_C_DEST */
return ts_obj;
}
template <class TYPE> TYPE *
ACE_TSS<TYPE>::ts_object (TYPE *new_ts_obj)
{
// Note, we shouldn't hold the keylock at this point because
// <ts_init> does it for us and we'll end up with deadlock
// otherwise...
if (!this->once_)
{
// Create and initialize thread-specific ts_obj.
if (this->ts_init () == -1)
return 0;
}
TYPE *ts_obj = 0;
#if defined (ACE_HAS_THR_C_DEST)
ACE_TSS_Adapter *tss_adapter = this->ts_value ();
if (tss_adapter != 0)
{
ts_obj = static_cast <TYPE *> (tss_adapter->ts_obj_);
// Don't delete tss_adapter yet. It can be double-deleted
// in case setspecific below fails.
}
ACE_TSS_Adapter *new_tss_adapter = 0;
ACE_NEW_RETURN (new_tss_adapter,
ACE_TSS_Adapter ((void *) new_ts_obj,
ACE_TSS<TYPE>::cleanup),
0);
if (this->ts_value (new_tss_adapter) == -1)
{
delete new_tss_adapter;
}
else
{
// Now it's fine to delete the old tss_adapter.
delete tss_adapter;
}
#else
ts_obj = this->ts_value ();
this->ts_value (new_ts_obj);
#endif /* ACE_HAS_THR_C_DEST */
return ts_obj;
}
ACE_ALLOC_HOOK_DEFINE(ACE_TSS_Guard)
template <class ACE_LOCK> void
ACE_TSS_Guard<ACE_LOCK>::dump (void) const
{
#if defined (ACE_HAS_DUMP)
ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("key_ = %d\n"), this->key_));
ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
#endif /* ACE_HAS_DUMP */
}
template <class ACE_LOCK> void
ACE_TSS_Guard<ACE_LOCK>::init_key (void)
{
this->key_ = ACE_OS::NULL_key;
ACE_Thread::keycreate (&this->key_,
#if defined (ACE_HAS_THR_C_DEST)
&ACE_TSS_C_cleanup,
#else
&ACE_TSS_Guard<ACE_LOCK>::cleanup,
#endif /* ACE_HAS_THR_C_DEST */
(void *) this);
}
template <class ACE_LOCK>
ACE_TSS_Guard<ACE_LOCK>::ACE_TSS_Guard (void)
{
this->init_key ();
}
template <class ACE_LOCK> int
ACE_TSS_Guard<ACE_LOCK>::release (void)
{
Guard_Type *guard = 0;
#if defined (ACE_HAS_THR_C_DEST)
ACE_TSS_Adapter *tss_adapter = 0;
void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
ACE_Thread::getspecific (this->key_, &temp);
tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
guard = static_cast <Guard_Type *> (tss_adapter->ts_obj_);
#else
void *temp = guard; // Need this temp to keep G++ from complaining.
ACE_Thread::getspecific (this->key_, &temp);
guard = static_cast <Guard_Type *> (temp);
#endif /* ACE_HAS_THR_C_DEST */
return guard->release ();
}
template <class ACE_LOCK> int
ACE_TSS_Guard<ACE_LOCK>::remove (void)
{
Guard_Type *guard = 0;
#if defined (ACE_HAS_THR_C_DEST)
ACE_TSS_Adapter *tss_adapter = 0;
void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
ACE_Thread::getspecific (this->key_, &temp);
tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
guard = static_cast <Guard_Type *> (tss_adapter->ts_obj_);
#else
void *temp = guard; // Need this temp to keep G++ from complaining.
ACE_Thread::getspecific (this->key_, &temp);
guard = static_cast <Guard_Type *> (temp);
#endif /* ACE_HAS_THR_C_DEST */
return guard->remove ();
}
template <class ACE_LOCK>
ACE_TSS_Guard<ACE_LOCK>::~ACE_TSS_Guard (void)
{
Guard_Type *guard = 0;
#if defined (ACE_HAS_THR_C_DEST)
ACE_TSS_Adapter *tss_adapter = 0;
void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
ACE_Thread::getspecific (this->key_, &temp);
tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
guard = static_cast <Guard_Type *> (tss_adapter->ts_obj_);
#else
void *temp = guard; // Need this temp to keep G++ from complaining.
ACE_Thread::getspecific (this->key_, &temp);
guard = static_cast <Guard_Type *> (temp);
#endif /* ACE_HAS_THR_C_DEST */
// Make sure that this pointer is NULL when we shut down...
ACE_Thread::setspecific (this->key_, 0);
ACE_Thread::keyfree (this->key_);
// Destructor releases lock.
delete guard;
}
template <class ACE_LOCK> void
ACE_TSS_Guard<ACE_LOCK>::cleanup (void *ptr)
{
// Destructor releases lock.
delete (Guard_Type *) ptr;
}
template <class ACE_LOCK>
ACE_TSS_Guard<ACE_LOCK>::ACE_TSS_Guard (ACE_LOCK &lock, bool block)
{
this->init_key ();
Guard_Type *guard = 0;
ACE_NEW (guard,
Guard_Type (lock, block));
#if defined (ACE_HAS_THR_C_DEST)
ACE_TSS_Adapter *tss_adapter = 0;
ACE_NEW (tss_adapter,
ACE_TSS_Adapter ((void *) guard,
ACE_TSS_Guard<ACE_LOCK>::cleanup));
ACE_Thread::setspecific (this->key_,
(void *) tss_adapter);
#else
ACE_Thread::setspecific (this->key_,
(void *) guard);
#endif /* ACE_HAS_THR_C_DEST */
}
template <class ACE_LOCK> int
ACE_TSS_Guard<ACE_LOCK>::acquire (void)
{
Guard_Type *guard = 0;
#if defined (ACE_HAS_THR_C_DEST)
ACE_TSS_Adapter *tss_adapter = 0;
void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
ACE_Thread::getspecific (this->key_, &temp);
tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
guard = static_cast <Guard_Type *> (tss_adapter->ts_obj_);
#else
void *temp = guard; // Need this temp to keep G++ from complaining.
ACE_Thread::getspecific (this->key_, &temp);
guard = static_cast <Guard_Type *> (temp);
#endif /* ACE_HAS_THR_C_DEST */
return guard->acquire ();
}
template <class ACE_LOCK> int
ACE_TSS_Guard<ACE_LOCK>::tryacquire (void)
{
Guard_Type *guard = 0;
#if defined (ACE_HAS_THR_C_DEST)
ACE_TSS_Adapter *tss_adapter = 0;
void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
ACE_Thread::getspecific (this->key_, &temp);
tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
guard = static_cast <Guard_Type *> (tss_adapter->ts_obj_);
#else
void *temp = guard; // Need this temp to keep G++ from complaining.
ACE_Thread::getspecific (this->key_, &temp);
guard = static_cast <Guard_Type *> (temp);
#endif /* ACE_HAS_THR_C_DEST */
return guard->tryacquire ();
}
template <class ACE_LOCK>
ACE_TSS_Write_Guard<ACE_LOCK>::ACE_TSS_Write_Guard (ACE_LOCK &lock,
bool block)
{
this->init_key ();
Guard_Type *guard = 0;
ACE_NEW (guard,
Write_Guard_Type (lock, block));
#if defined (ACE_HAS_THR_C_DEST)
ACE_TSS_Adapter *tss_adapter = 0;
ACE_NEW (tss_adapter,
ACE_TSS_Adapter ((void *) guard,
ACE_TSS_Guard<ACE_LOCK>::cleanup));
ACE_Thread::setspecific (this->key_, (void *) tss_adapter);
#else
ACE_Thread::setspecific (this->key_, (void *) guard);
#endif /* ACE_HAS_THR_C_DEST */
}
template <class ACE_LOCK> int
ACE_TSS_Write_Guard<ACE_LOCK>::acquire (void)
{
Write_Guard_Type *guard = 0;
#if defined (ACE_HAS_THR_C_DEST)
ACE_TSS_Adapter *tss_adapter = 0;
void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
ACE_Thread::getspecific (this->key_, &temp);
tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
guard = static_cast <Write_Guard_Type *> (tss_adapter->ts_obj_);
#else
void *temp = guard; // Need this temp to keep G++ from complaining.
ACE_Thread::getspecific (this->key_, &temp);
guard = static_cast <Write_Guard_Type *> (temp);
#endif /* ACE_HAS_THR_C_DEST */
return guard->acquire_write ();
}
template <class ACE_LOCK> int
ACE_TSS_Write_Guard<ACE_LOCK>::tryacquire (void)
{
Write_Guard_Type *guard = 0;
#if defined (ACE_HAS_THR_C_DEST)
ACE_TSS_Adapter *tss_adapter = 0;
void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
ACE_Thread::getspecific (this->key_, &temp);
tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
guard = static_cast <Write_Guard_Type *> (tss_adapter->ts_obj_);
#else
void *temp = guard; // Need this temp to keep G++ from complaining.
ACE_Thread::getspecific (this->key_, &temp);
guard = static_cast <Write_Guard_Type *> (temp);
#endif /* ACE_HAS_THR_C_DEST */
return guard->tryacquire_write ();
}
template <class ACE_LOCK> int
ACE_TSS_Write_Guard<ACE_LOCK>::acquire_write (void)
{
return this->acquire ();
}
template <class ACE_LOCK> int
ACE_TSS_Write_Guard<ACE_LOCK>::tryacquire_write (void)
{
return this->tryacquire ();
}
template <class ACE_LOCK> void
ACE_TSS_Write_Guard<ACE_LOCK>::dump (void) const
{
#if defined (ACE_HAS_DUMP)
ACE_TSS_Guard<ACE_LOCK>::dump ();
#endif /* ACE_HAS_DUMP */
}
template <class ACE_LOCK>
ACE_TSS_Read_Guard<ACE_LOCK>::ACE_TSS_Read_Guard (ACE_LOCK &lock, bool block)
{
this->init_key ();
Guard_Type *guard = 0;
ACE_NEW (guard,
Read_Guard_Type (lock, block));
#if defined (ACE_HAS_THR_C_DEST)
ACE_TSS_Adapter *tss_adapter;
ACE_NEW (tss_adapter,
ACE_TSS_Adapter ((void *)guard,
ACE_TSS_Guard<ACE_LOCK>::cleanup));
ACE_Thread::setspecific (this->key_,
(void *) tss_adapter);
#else
ACE_Thread::setspecific (this->key_,
(void *) guard);
#endif /* ACE_HAS_THR_C_DEST */
}
template <class ACE_LOCK> int
ACE_TSS_Read_Guard<ACE_LOCK>::acquire (void)
{
Read_Guard_Type *guard = 0;
#if defined (ACE_HAS_THR_C_DEST)
ACE_TSS_Adapter *tss_adapter = 0;
void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
ACE_Thread::getspecific (this->key_, &temp);
tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
guard = static_cast <Read_Guard_Type *> (tss_adapter->ts_obj_);
#else
void *temp = guard; // Need this temp to keep G++ from complaining.
ACE_Thread::getspecific (this->key_, &temp);
guard = static_cast <Read_Guard_Type *> (temp);
#endif /* ACE_HAS_THR_C_DEST */
return guard->acquire_read ();
}
template <class ACE_LOCK> int
ACE_TSS_Read_Guard<ACE_LOCK>::tryacquire (void)
{
Read_Guard_Type *guard = 0;
#if defined (ACE_HAS_THR_C_DEST)
ACE_TSS_Adapter *tss_adapter = 0;
void *temp = tss_adapter; // Need this temp to keep G++ from complaining.
ACE_Thread::getspecific (this->key_, &temp);
tss_adapter = static_cast <ACE_TSS_Adapter *> (temp);
guard = static_cast <Read_Guard_Type *> (tss_adapter->ts_obj_);
#else
void *temp = guard; // Need this temp to keep G++ from complaining.
ACE_Thread::getspecific (this->key_, &temp);
guard = static_cast <Read_Guard_Type *> (temp);
#endif /* ACE_HAS_THR_C_DEST */
return guard->tryacquire_read ();
}
template <class ACE_LOCK> int
ACE_TSS_Read_Guard<ACE_LOCK>::acquire_read (void)
{
return this->acquire ();
}
template <class ACE_LOCK> int
ACE_TSS_Read_Guard<ACE_LOCK>::tryacquire_read (void)
{
return this->tryacquire ();
}
template <class ACE_LOCK> void
ACE_TSS_Read_Guard<ACE_LOCK>::dump (void) const
{
#if defined (ACE_HAS_DUMP)
ACE_TSS_Guard<ACE_LOCK>::dump ();
#endif /* ACE_HAS_DUMP */
}
#endif /* defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION)) */
ACE_END_VERSIONED_NAMESPACE_DECL
#endif /* ACE_TSS_T_CPP */
|