diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-07-30 06:28:49 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-07-30 06:28:49 +0000 |
commit | 1b34004667b0d1a6b1e2c7ab73f7433c08b0f08c (patch) | |
tree | e2583d7533acb8b46772fe0dc69da720478f4096 | |
parent | 579c2a28e63d511ce835d148230c5fd247730960 (diff) | |
download | ATCD-1b34004667b0d1a6b1e2c7ab73f7433c08b0f08c.tar.gz |
*** empty log message ***
-rw-r--r-- | ChangeLog-98b | 9 | ||||
-rw-r--r-- | ace/Svc_Conf_y.cpp | 20 | ||||
-rw-r--r-- | ace/Synch_T.cpp | 268 | ||||
-rw-r--r-- | ace/Synch_T.h | 6 |
4 files changed, 184 insertions, 119 deletions
diff --git a/ChangeLog-98b b/ChangeLog-98b index c3d7e2d4c4f..825ba04f052 100644 --- a/ChangeLog-98b +++ b/ChangeLog-98b @@ -1,3 +1,12 @@ +Thu Jul 30 01:12:30 1998 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> + + * ace/Synch_T.cpp: It wasn't possible to call ts_object() to set + an initial zero pointer value. The solution is to give + ts_object() the same ability to initialize the key as ts_get(). + I also factored out some common code into a new method called + ts_init(). Thanks to Bob McWhirter <bob@netwrench.com> for + reporting this. + Wed Jul 29 23:58:04 1998 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu> * examples/Reactor/Ntalker: Added a README file and made some diff --git a/ace/Svc_Conf_y.cpp b/ace/Svc_Conf_y.cpp index 3779f639279..fa4c4553adb 100644 --- a/ace/Svc_Conf_y.cpp +++ b/ace/Svc_Conf_y.cpp @@ -254,7 +254,7 @@ ACE_YYSTYPE ace_yyvs[ACE_YYSTACKSIZE]; // messages. void -ace_yyerror (char *s) +ace_yyerror (const char *s) { ACE_ERROR ((LM_ERROR, ASYS_TEXT ("[error %d] on line %d: %s\n"), ++ace_yyerrno, ace_yylineno, ASYS_WIDE_STRING (s))); @@ -410,7 +410,7 @@ int ace_yyindent; #endif /* ACE_YYDEBUG_INDENT */ #ifndef ACE_YYDEBUG_REDUCE #ifdef __cplusplus -void ACE_YYDEBUG_REDUCE(int /* ace_yynew_state */, int /* ace_yyrule_num */, char *ace_yyrule_string, int ace_yynew_indent, int ace_yyrhs_count) +void ACE_YYDEBUG_REDUCE(int ace_yynew_state, int ace_yyrule_num, char *ace_yyrule_string, int ace_yynew_indent, int ace_yyrhs_count) #else ACE_YYDEBUG_REDUCE(ace_yynew_state, ace_yyrule_num, ace_yyrule_string, ace_yynew_indent, ace_yyrhs_count) int ace_yynew_state; @@ -440,7 +440,7 @@ int ace_yyrhs_count; #endif /* ACE_YYDEBUG_REDUCE */ #ifndef ACE_YYDEBUG_SHIFT_LEXEME #ifdef __cplusplus -void ACE_YYDEBUG_SHIFT_LEXEME(int /* ace_yyold_state */, int /* ace_yynew_state*/, char *ace_yytoken_string, int ace_yynew_indent) +void ACE_YYDEBUG_SHIFT_LEXEME(int ace_yyold_state, int ace_yynew_state, char *ace_yytoken_string, int ace_yynew_indent) #else ACE_YYDEBUG_SHIFT_LEXEME(ace_yyold_state, ace_yynew_state, ace_yytoken_string, ace_yynew_indent) int ace_yyold_state; @@ -455,7 +455,7 @@ int ace_yynew_indent; #endif /* ACE_YYDEBUG_SHIFT_LEXEME */ #ifndef ACE_YYDEBUG_LOOK_AHEAD #ifdef __cplusplus -void ACE_YYDEBUG_LOOK_AHEAD(int /* ace_yynew_state */, int ace_yytoken_num, char *ace_yytoken_string, int ace_yyindent) +void ACE_YYDEBUG_LOOK_AHEAD(int ace_yynew_state, int ace_yytoken_num, char *ace_yytoken_string, int ace_yyindent) #else ACE_YYDEBUG_LOOK_AHEAD(ace_yynew_state, ace_yytoken_num, ace_yytoken_string, ace_yyindent) int ace_yynew_state; @@ -472,7 +472,7 @@ int ace_yyindent; #endif /* ACE_YYDEBUG_LOOK_AHEAD */ #ifndef ACE_YYDEBUG_DISCARD_STATE #ifdef __cplusplus -void ACE_YYDEBUG_DISCARD_STATE(int /* ace_yynew_state */, int ace_yyindent) +void ACE_YYDEBUG_DISCARD_STATE(int ace_yynew_state, int ace_yyindent) #else ACE_YYDEBUG_DISCARD_STATE(ace_yynew_state, ace_yyindent) int ace_yynew_state; @@ -500,7 +500,7 @@ int ace_yyindent; #endif /* ACE_YYDEBUG_DISCARD_STATE */ #ifndef ACE_YYDEBUG_DISCARD_TOKEN #ifdef __cplusplus -void ACE_YYDEBUG_DISCARD_TOKEN(int /* ace_yynew_state */, int /* ace_yytoken_num */, char *ace_yytoken_string, int ace_yyindent) +void ACE_YYDEBUG_DISCARD_TOKEN(int ace_yynew_state, int ace_yytoken_num, char *ace_yytoken_string, int ace_yyindent) #else ACE_YYDEBUG_DISCARD_TOKEN(ace_yynew_state, ace_yytoken_num, ace_yytoken_string, ace_yyindent) int ace_yynew_state; @@ -515,7 +515,7 @@ int ace_yyindent; #endif /* ACE_YYDEBUG_DISCARD_TOKEN */ #ifndef ACE_YYDEBUG_SHIFT_ERROR_LEXEME #ifdef __cplusplus -void ACE_YYDEBUG_SHIFT_ERROR_LEXEME(int /* ace_yyold_state */, int /* ace_yynew_state */, int ace_yyindent) +void ACE_YYDEBUG_SHIFT_ERROR_LEXEME(int ace_yyold_state, int ace_yynew_state, int ace_yyindent) #else ACE_YYDEBUG_SHIFT_ERROR_LEXEME(ace_yyold_state, ace_yynew_state, ace_yyindent) int ace_yyold_state; @@ -541,7 +541,7 @@ ace_yyparse() extern char *ace_foo(); #endif - if ((ace_yys = ACE_OS::getenv("ACE_YYDEBUG"))) + if (ace_yys = ACE_OS::getenv("ACE_YYDEBUG")) { ace_yyn = *ace_yys; if (ace_yyn >= '0' && ace_yyn <= '9') @@ -558,7 +558,7 @@ ace_yyparse() *ace_yyssp = ace_yystate = 0; ace_yyloop: - if ((ace_yyn = ace_yydefred[ace_yystate])) goto ace_yyreduce; + if (ace_yyn = ace_yydefred[ace_yystate]) goto ace_yyreduce; if (ace_yychar < 0) { if ((ace_yychar = ace_yylex()) < 0) ace_yychar = 0; @@ -668,7 +668,7 @@ ace_yyinrecovery: if (5 < ace_yydebug) printf("ace_yydebug: state %d, error recovery discards token %d (%s)\n", ace_yystate, ace_yychar, ace_yys); - else + else ACE_YYDEBUG_DISCARD_TOKEN(ace_yystate, ace_yychar, ace_yys, ace_yyssp-ace_yyss); } #endif diff --git a/ace/Synch_T.cpp b/ace/Synch_T.cpp index ec11ea46016..959acb8fc10 100644 --- a/ace/Synch_T.cpp +++ b/ace/Synch_T.cpp @@ -155,16 +155,22 @@ ACE_Condition<MUTEX>::ACE_Condition (MUTEX &m, : mutex_ (m) { // ACE_TRACE ("ACE_Condition<MUTEX>::ACE_Condition"); + if (ACE_OS::cond_init (&this->cond_, type, name, arg) != 0) - ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), ASYS_TEXT ("ACE_Condition::ACE_Condition"))); + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("%p\n"), + ASYS_TEXT ("ACE_Condition::ACE_Condition"))); } template <class MUTEX> ACE_Condition<MUTEX>::~ACE_Condition (void) { // ACE_TRACE ("ACE_Condition<MUTEX>::~ACE_Condition"); + if (this->remove () == -1) - ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), ASYS_TEXT ("ACE_Condition::~ACE_Condition"))); + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("%p\n"), + ASYS_TEXT ("ACE_Condition::~ACE_Condition"))); } template <class MUTEX> int @@ -254,6 +260,38 @@ ACE_TSS<TYPE>::cleanup (void *ptr) delete (TYPE *) ptr; } +template <class TYPE> int +ACE_TSS<TYPE>::ts_init (void) const +{ + // Insure that we are serialized! + ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, (ACE_Thread_Mutex &) this->keylock_, 0); + + // Use the Double-Check pattern to make sure we only create the key + // once! + if (this->once_ == 0) + { + 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 */ + (void *) this) != 0) + return -1; // Major problems, this should *never* happen! + else + { + // This *must* come last to avoid race conditions! Note that + // we need to "cast away const..." + // BTW, if this code doesn't compile, please try the following instead. + // *(int *) &this->once_ = 1; + ACE_const_cast (int, this->once_) = 1; + return 0; + } + } + else + return -1; +} + template <class TYPE> ACE_TSS<TYPE>::ACE_TSS (TYPE *ts_obj) : once_ (0), @@ -267,15 +305,7 @@ ACE_TSS<TYPE>::ACE_TSS (TYPE *ts_obj) if (ts_obj != 0) { - ACE_ASSERT (this->once_ == 0); - - 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 */ - (void *) this) != 0) + if (this->ts_init () == -1) { int errnum = errno; // What should we do if this call fails?! @@ -283,29 +313,36 @@ ACE_TSS<TYPE>::ACE_TSS (TYPE *ts_obj) ::MessageBox (NULL, L"ACE_Thread::keycreate() failed!", L"ACE_TSS::ACE_TSS", MB_OK); #else - ACE_OS::fprintf (stderr, "ACE_Thread::keycreate() failed!"); + ACE_OS::fprintf (stderr, + "ACE_Thread::keycreate() failed!"); #endif /* ACE_HAS_WINCE */ errno = errnum; return; } - this->once_ = 1; - #if defined (ACE_HAS_THR_C_DEST) - // Encapsulate a ts_obj and it's destructor in an ACE_TSS_Adapter + // Encapsulate a ts_obj and it's destructor in an + // ACE_TSS_Adapter. ACE_TSS_Adapter *tss_adapter; ACE_NEW (tss_adapter, - ACE_TSS_Adapter ((void *) ts_obj, ACE_TSS<TYPE>::cleanup)); + ACE_TSS_Adapter ((void *) ts_obj, + ACE_TSS<TYPE>::cleanup)); // Put the adapter in thread specific storage - if (ACE_Thread::setspecific (this->key_, (void *) tss_adapter) != 0) + if (ACE_Thread::setspecific (this->key_, + (void *) tss_adapter) != 0) { delete tss_adapter; - ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), ASYS_TEXT ("ACE_Thread::setspecific() failed!"))); + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("%p\n"), + ASYS_TEXT ("ACE_Thread::setspecific() failed!"))); } #else - if (ACE_Thread::setspecific (this->key_, (void *) ts_obj) != 0) - ACE_ERROR ((LM_ERROR, ASYS_TEXT ("%p\n"), ASYS_TEXT ("ACE_Thread::setspecific() failed!"))); + if (ACE_Thread::setspecific (this->key_, + (void *) ts_obj) != 0) + ACE_ERROR ((LM_ERROR, + ASYS_TEXT ("%p\n"), + ASYS_TEXT ("ACE_Thread::setspecific() failed!"))); #endif /* ACE_HAS_THR_C_DEST */ } } @@ -313,30 +350,9 @@ ACE_TSS<TYPE>::ACE_TSS (TYPE *ts_obj) template <class TYPE> TYPE * ACE_TSS<TYPE>::ts_get (void) const { - // Create and initialize thread-specific ts_obj. if (this->once_ == 0) - { - // Insure that we are serialized! - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, (ACE_Thread_Mutex &) this->keylock_, 0); - - // Use the Double-Check pattern to make sure we only create the - // key once! - if (this->once_ == 0) - { - if (ACE_Thread::keycreate ((ACE_thread_key_t *) &this->key_, -#if defined (ACE_HAS_THR_C_DEST) - &ACE_TSS_C_cleanup, -#else - &ACE_TSS<TYPE>::cleanup, -#endif /* ACE_HAS_THR_C_DEST */ - (void *) this) != 0) - return 0; // Major problems, this should *never* happen! - else - // This *must* come last to avoid race conditions! Note - // that we need to "cast away const..." - *(int *) &this->once_ = 1; - } - } + // Create and initialize thread-specific ts_obj. + this->ts_init (); TYPE *ts_obj = 0; @@ -344,7 +360,8 @@ ACE_TSS<TYPE>::ts_get (void) const ACE_TSS_Adapter *tss_adapter = 0; // Get the adapter from thread-specific storage - if (ACE_Thread::getspecific (this->key_, (void **) &tss_adapter) == -1) + if (ACE_Thread::getspecific (this->key_, + (void **) &tss_adapter) == -1) return 0; // This should not happen! // Check to see if this is the first time in for this thread. @@ -352,7 +369,8 @@ ACE_TSS<TYPE>::ts_get (void) const #else // Get the ts_obj from thread-specific storage. Note that no locks // are required here... - if (ACE_Thread::getspecific (this->key_, (void **) &ts_obj) == -1) + if (ACE_Thread::getspecific (this->key_, + (void **) &ts_obj) == -1) return 0; // This should not happen! // Check to see if this is the first time in for this thread. @@ -368,12 +386,15 @@ ACE_TSS<TYPE>::ts_get (void) const return 0; #if defined (ACE_HAS_THR_C_DEST) - // Encapsulate a ts_obj and it's destructor in an ACE_TSS_Adapter + // 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); + ACE_TSS_Adapter (ts_obj, + ACE_TSS<TYPE>::cleanup), 0); // Put the adapter in thread specific storage - if (ACE_Thread::setspecific (this->key_, (void *) tss_adapter) != 0) + if (ACE_Thread::setspecific (this->key_, + (void *) tss_adapter) != 0) { delete tss_adapter; delete ts_obj; @@ -382,7 +403,8 @@ ACE_TSS<TYPE>::ts_get (void) const #else // Store the dynamically allocated pointer in thread-specific // storage. - if (ACE_Thread::setspecific (this->key_, (void *) ts_obj) != 0) + if (ACE_Thread::setspecific (this->key_, + (void *) ts_obj) != 0) { delete ts_obj; return 0; // Major problems, this should *never* happen! @@ -391,7 +413,8 @@ ACE_TSS<TYPE>::ts_get (void) const } #if defined (ACE_HAS_THR_C_DEST) - return (TYPE *) tss_adapter->ts_obj_; // return the underlying ts object + // Return the underlying ts object. + return (TYPE *) tss_adapter->ts_obj_; #else return ts_obj; #endif /* ACE_HAS_THR_C_DEST */ @@ -416,13 +439,15 @@ ACE_TSS<TYPE>::ts_object (void) const ACE_TSS_Adapter *tss_adapter = 0; // Get the tss adapter from thread-specific storage - if (ACE_Thread::getspecific (this->key_, (void **) &tss_adapter) == -1) + if (ACE_Thread::getspecific (this->key_, + (void **) &tss_adapter) == -1) return 0; // This should not happen! else if (tss_adapter != 0) // Extract the real TS object. ts_obj = (TYPE *) tss_adapter->ts_obj_; #else - if (ACE_Thread::getspecific (this->key_, (void **) &ts_obj) == -1) + if (ACE_Thread::getspecific (this->key_, + (void **) &ts_obj) == -1) return 0; // This should not happen! #endif /* ACE_HAS_THR_C_DEST */ return ts_obj; @@ -435,42 +460,46 @@ ACE_TSS<TYPE>::ts_object (TYPE *new_ts_obj) // Ensure that we are serialized! ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->keylock_, 0); - if (this->once_ == 0) // Return 0 if we've never been initialized. - return 0; - else - { - TYPE *ts_obj = 0; + if (this->once_ == 0) + // Create and initialize thread-specific ts_obj. + this->ts_init (); + + TYPE *ts_obj = 0; #if defined (ACE_HAS_THR_C_DEST) - ACE_TSS_Adapter *tss_adapter = 0; + ACE_TSS_Adapter *tss_adapter = 0; - if (ACE_Thread::getspecific (this->key_, (void **) &tss_adapter) == -1) - return 0; // This should not happen! + if (ACE_Thread::getspecific (this->key_, + (void **) &tss_adapter) == -1) + return 0; // This should not happen! - if (tss_adapter != 0) - { - ts_obj = (TYPE *) tss_adapter->ts_obj_; - delete tss_adapter; // don't need this anymore - } + if (tss_adapter != 0) + { + ts_obj = (TYPE *) tss_adapter->ts_obj_; + delete tss_adapter; // don't need this anymore + } - ACE_NEW_RETURN (tss_adapter, - ACE_TSS_Adapter ((void *)new_ts_obj, ACE_TSS<TYPE>::cleanup), - 0); + ACE_NEW_RETURN (tss_adapter, + ACE_TSS_Adapter ((void *) new_ts_obj, + ACE_TSS<TYPE>::cleanup), + 0); - if (ACE_Thread::setspecific (this->key_, (void *) tss_adapter) == -1) - { - delete tss_adapter; - return ts_obj; // This should not happen! - } + if (ACE_Thread::setspecific (this->key_, + (void *) tss_adapter) == -1) + { + delete tss_adapter; + return ts_obj; // This should not happen! + } #else - if (ACE_Thread::getspecific (this->key_, (void **) &ts_obj) == -1) - return 0; // This should not happen! - if (ACE_Thread::setspecific (this->key_, (void *) new_ts_obj) == -1) - return ts_obj; // This should not happen! + if (ACE_Thread::getspecific (this->key_, + (void **) &ts_obj) == -1) + return 0; // This should not happen! + if (ACE_Thread::setspecific (this->key_, + (void *) new_ts_obj) == -1) + return ts_obj; // This should not happen! #endif /* ACE_HAS_THR_C_DEST */ - else - return ts_obj; - } + else + return ts_obj; } ACE_ALLOC_HOOK_DEFINE(ACE_TSS_Guard) @@ -517,10 +546,12 @@ ACE_TSS_Guard<ACE_LOCK>::release (void) #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter = 0; - ACE_Thread::getspecific (this->key_, (void **) &tss_adapter); + ACE_Thread::getspecific (this->key_, + (void **) &tss_adapter); guard = (ACE_Guard<ACE_LOCK> *)tss_adapter->ts_obj_; #else - ACE_Thread::getspecific (this->key_, (void **) &guard); + ACE_Thread::getspecific (this->key_, + (void **) &guard); #endif /* ACE_HAS_THR_C_DEST */ return guard->release (); @@ -535,10 +566,12 @@ ACE_TSS_Guard<ACE_LOCK>::remove (void) #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter = 0; - ACE_Thread::getspecific (this->key_, (void **) &tss_adapter); - guard = (ACE_Guard<ACE_LOCK> *)tss_adapter->ts_obj_; + ACE_Thread::getspecific (this->key_, + (void **) &tss_adapter); + guard = (ACE_Guard<ACE_LOCK> *) tss_adapter->ts_obj_; #else - ACE_Thread::getspecific (this->key_, (void **) &guard); + ACE_Thread::getspecific (this->key_, + (void **) &guard); #endif /* ACE_HAS_THR_C_DEST */ return guard->remove (); @@ -553,10 +586,12 @@ ACE_TSS_Guard<ACE_LOCK>::~ACE_TSS_Guard (void) #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter = 0; - ACE_Thread::getspecific (this->key_, (void **) &tss_adapter); + ACE_Thread::getspecific (this->key_, + (void **) &tss_adapter); guard = (ACE_Guard<ACE_LOCK> *) tss_adapter->ts_obj_; #else - ACE_Thread::getspecific (this->key_, (void **) &guard); + ACE_Thread::getspecific (this->key_, + (void **) &guard); #endif /* ACE_HAS_THR_C_DEST */ // Make sure that this pointer is NULL when we shut down... @@ -589,9 +624,11 @@ ACE_TSS_Guard<ACE_LOCK>::ACE_TSS_Guard (ACE_LOCK &lock, int block) ACE_NEW (tss_adapter, ACE_TSS_Adapter ((void *) guard, ACE_TSS_Guard<ACE_LOCK>::cleanup)); - ACE_Thread::setspecific (this->key_, (void *) tss_adapter); + ACE_Thread::setspecific (this->key_, + (void *) tss_adapter); #else - ACE_Thread::setspecific (this->key_, (void *) guard); + ACE_Thread::setspecific (this->key_, + (void *) guard); #endif /* ACE_HAS_THR_C_DEST */ } @@ -604,10 +641,12 @@ ACE_TSS_Guard<ACE_LOCK>::acquire (void) #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter = 0; - ACE_Thread::getspecific (this->key_, (void **) &tss_adapter); + ACE_Thread::getspecific (this->key_, + (void **) &tss_adapter); guard = (ACE_Guard<ACE_LOCK> *) tss_adapter->ts_obj_; #else - ACE_Thread::getspecific (this->key_, (void **) &guard); + ACE_Thread::getspecific (this->key_, + (void **) &guard); #endif /* ACE_HAS_THR_C_DEST */ return guard->acquire (); @@ -622,17 +661,20 @@ ACE_TSS_Guard<ACE_LOCK>::tryacquire (void) #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter = 0; - ACE_Thread::getspecific (this->key_, (void **) &tss_adapter); + ACE_Thread::getspecific (this->key_, + (void **) &tss_adapter); guard = (ACE_Guard<ACE_LOCK> *) tss_adapter->ts_obj_; #else - ACE_Thread::getspecific (this->key_, (void **) &guard); + ACE_Thread::getspecific (this->key_, + (void **) &guard); #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, int block) +ACE_TSS_Write_Guard<ACE_LOCK>::ACE_TSS_Write_Guard (ACE_LOCK &lock, + int block) { // ACE_TRACE ("ACE_TSS_Write_Guard<ACE_LOCK>::ACE_TSS_Write_Guard"); @@ -645,9 +687,11 @@ ACE_TSS_Write_Guard<ACE_LOCK>::ACE_TSS_Write_Guard (ACE_LOCK &lock, int block) ACE_NEW (tss_adapter, ACE_TSS_Adapter ((void *) guard, ACE_TSS_Guard<ACE_LOCK>::cleanup)); - ACE_Thread::setspecific (this->key_, (void *) tss_adapter); + ACE_Thread::setspecific (this->key_, + (void *) tss_adapter); #else - ACE_Thread::setspecific (this->key_, (void *) guard); + ACE_Thread::setspecific (this->key_, + (void *) guard); #endif /* ACE_HAS_THR_C_DEST */ } @@ -660,10 +704,12 @@ ACE_TSS_Write_Guard<ACE_LOCK>::acquire (void) #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter = 0; - ACE_Thread::getspecific (this->key_, (void **) &tss_adapter); + ACE_Thread::getspecific (this->key_, + (void **) &tss_adapter); guard = (ACE_Guard<ACE_LOCK> *) tss_adapter->ts_obj_; #else - ACE_Thread::getspecific (this->key_, (void **) &guard); + ACE_Thread::getspecific (this->key_, + (void **) &guard); #endif /* ACE_HAS_THR_C_DEST */ return guard->acquire_write (); @@ -678,10 +724,12 @@ ACE_TSS_Write_Guard<ACE_LOCK>::tryacquire (void) #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter = 0; - ACE_Thread::getspecific (this->key_, (void **) &tss_adapter); + ACE_Thread::getspecific (this->key_, + (void **) &tss_adapter); guard = (ACE_Guard<ACE_LOCK> *) tss_adapter->ts_obj_; #else - ACE_Thread::getspecific (this->key_, (void **) &guard); + ACE_Thread::getspecific (this->key_, + (void **) &guard); #endif /* ACE_HAS_THR_C_DEST */ return guard->tryacquire_write (); @@ -724,9 +772,11 @@ ACE_TSS_Read_Guard<ACE_LOCK>::ACE_TSS_Read_Guard (ACE_LOCK &lock, int block) ACE_NEW (tss_adapter, ACE_TSS_Adapter ((void *)guard, ACE_TSS_Guard<ACE_LOCK>::cleanup)); - ACE_Thread::setspecific (this->key_, (void *) tss_adapter); + ACE_Thread::setspecific (this->key_, + (void *) tss_adapter); #else - ACE_Thread::setspecific (this->key_, (void *) guard); + ACE_Thread::setspecific (this->key_, + (void *) guard); #endif /* ACE_HAS_THR_C_DEST */ } @@ -739,10 +789,12 @@ ACE_TSS_Read_Guard<ACE_LOCK>::acquire (void) #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter = 0; - ACE_Thread::getspecific (this->key_, (void **) &tss_adapter); - guard = (ACE_Guard<ACE_LOCK> *)tss_adapter->ts_obj_; + ACE_Thread::getspecific (this->key_, + (void **) &tss_adapter); + guard = (ACE_Guard<ACE_LOCK> *) tss_adapter->ts_obj_; #else - ACE_Thread::getspecific (this->key_, (void **) &guard); + ACE_Thread::getspecific (this->key_, + (void **) &guard); #endif /* ACE_HAS_THR_C_DEST */ return guard->acquire_read (); @@ -757,10 +809,12 @@ ACE_TSS_Read_Guard<ACE_LOCK>::tryacquire (void) #if defined (ACE_HAS_THR_C_DEST) ACE_TSS_Adapter *tss_adapter = 0; - ACE_Thread::getspecific (this->key_, (void **) &tss_adapter); + ACE_Thread::getspecific (this->key_, + (void **) &tss_adapter); guard = (ACE_Guard<ACE_LOCK> *) tss_adapter->ts_obj_; #else - ACE_Thread::getspecific (this->key_, (void **) &guard); + ACE_Thread::getspecific (this->key_, + (void **) &guard); #endif /* ACE_HAS_THR_C_DEST */ return guard->tryacquire_read (); diff --git a/ace/Synch_T.h b/ace/Synch_T.h index 295045082d3..91951d8759a 100644 --- a/ace/Synch_T.h +++ b/ace/Synch_T.h @@ -268,8 +268,7 @@ public: TYPE *ts_object (TYPE *); // Set the thread-specific object for the key associated with this - // object. Returns 0 if the data has never been initialized, - // otherwise returns a pointer to the previous value for the data. + // object. TYPE *operator-> () const; // Use a "smart pointer" to get the thread-specific object @@ -294,6 +293,9 @@ protected: // Actually implements the code that retrieves the object from // thread-specific storage. + int ts_init (void) const; + // Factors out common code for initializing TSS. + #if !(defined (ACE_HAS_THREADS) && (defined (ACE_HAS_THREAD_SPECIFIC_STORAGE) || defined (ACE_HAS_TSS_EMULATION))) TYPE *type_; // This implementation only works for non-threading systems... |