Skip to content

Commit

Permalink
renamed the MSE_DECLARE_THREAD_LOCAL() macro
Browse files Browse the repository at this point in the history
  • Loading branch information
xxxx committed Nov 3, 2018
1 parent e5472a7 commit 8ff45f5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
16 changes: 8 additions & 8 deletions msestaticimmutable.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ namespace mse {
#endif /*MSE_STATICPOINTER_DISABLED*/
}

#define MSE_RSV_DECLARE_STATIC_IMMUTABLE(type) static mse::rsv::TStaticImmutableObj<type>
#define MSE_DECLARE_STATIC_IMMUTABLE(type) static mse::rsv::TStaticImmutableObj<type>
#define MSE_RSV_DECLARE_GLOBAL_IMMUTABLE(type) mse::rsv::TStaticImmutableObj<type>


Expand Down Expand Up @@ -598,7 +598,7 @@ namespace mse {

{
shareable_A a(7);
MSE_RSV_DECLARE_STATIC_IMMUTABLE(shareable_A) static_a(7);
MSE_DECLARE_STATIC_IMMUTABLE(shareable_A) static_a(7);

assert(a.b == static_a.b);
shareable_A_native_ptr = std::addressof(a);
Expand All @@ -621,7 +621,7 @@ namespace mse {
}

shareable_A a2 = a;
MSE_RSV_DECLARE_STATIC_IMMUTABLE(shareable_A) static_a2 = static_a;
MSE_DECLARE_STATIC_IMMUTABLE(shareable_A) static_a2 = static_a;
static_a2 = a;
static_a2 = static_a;

Expand All @@ -639,7 +639,7 @@ namespace mse {
/* Polymorphic conversions that would not be supported by mse::TRegisteredPointer. */
class GE : public E {};
typedef mse::rsv::TAsyncShareableObj<GE> shareable_GE;
MSE_RSV_DECLARE_STATIC_IMMUTABLE(shareable_GE) static_gd;
MSE_DECLARE_STATIC_IMMUTABLE(shareable_GE) static_gd;
mse::rsv::TStaticImmutableFixedPointer<shareable_GE> GE_static_ifptr1 = &static_gd;
mse::rsv::TStaticImmutableFixedPointer<E> E_static_ifptr5 = GE_static_ifptr1;
mse::rsv::TStaticImmutableFixedPointer<E> E_static_fptr2(&static_gd);
Expand All @@ -666,7 +666,7 @@ namespace mse {
~B() {}
};

MSE_RSV_DECLARE_STATIC_IMMUTABLE(shareable_A) a_scpobj(5);
MSE_DECLARE_STATIC_IMMUTABLE(shareable_A) a_scpobj(5);
int res1 = (&a_scpobj)->b;
int res2 = B::foo2(&a_scpobj);
int res3 = B::foo3(&a_scpobj);
Expand All @@ -679,7 +679,7 @@ namespace mse {

{
shareable_A a(7);
MSE_RSV_DECLARE_STATIC_IMMUTABLE(shareable_A) static_a(7);
MSE_DECLARE_STATIC_IMMUTABLE(shareable_A) static_a(7);

assert(a.b == static_a.b);
shareable_A_native_ptr = std::addressof(a);
Expand All @@ -702,7 +702,7 @@ namespace mse {
}

shareable_A a2 = a;
MSE_RSV_DECLARE_STATIC_IMMUTABLE(shareable_A) static_a2 = static_a;
MSE_DECLARE_STATIC_IMMUTABLE(shareable_A) static_a2 = static_a;
static_a2 = a;
static_a2 = static_a;

Expand All @@ -720,7 +720,7 @@ namespace mse {
/* Polymorphic conversions that would not be supported by mse::TRegisteredPointer. */
class GE : public E {};
typedef mse::rsv::TAsyncShareableObj<GE> shareable_GE;
MSE_RSV_DECLARE_STATIC_IMMUTABLE(shareable_GE) static_gd;
MSE_DECLARE_STATIC_IMMUTABLE(shareable_GE) static_gd;
mse::rsv::TStaticImmutableFixedPointer<shareable_GE> GE_static_ifptr1 = &static_gd;
mse::rsv::TStaticImmutableFixedPointer<E> E_static_ptr5(GE_static_ifptr1);
mse::rsv::TStaticImmutableFixedPointer<E> E_static_ifptr2(&static_gd);
Expand Down
26 changes: 13 additions & 13 deletions msethreadlocal.h
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,10 @@ namespace mse {
#endif /*MSE_THREADLOCALPOINTER_DISABLED*/
}

#define MSE_RSV_DECLARE_THREAD_LOCAL(type) thread_local mse::rsv::TThreadLocalObj<type>
#define MSE_RSV_DECLARE_THREAD_LOCAL_CONST(type) thread_local const mse::rsv::TThreadLocalObj<type>
#define MSE_RSV_DECLARE_THREAD_LOCAL_GLOBAL(type) MSE_RSV_DECLARE_THREAD_LOCAL(type)
#define MSE_RSV_DECLARE_THREAD_LOCAL_GLOBAL_CONST(type) MSE_RSV_DECLARE_THREAD_LOCAL_CONST(type)
#define MSE_DECLARE_THREAD_LOCAL(type) thread_local mse::rsv::TThreadLocalObj<type>
#define MSE_DECLARE_THREAD_LOCAL_CONST(type) thread_local const mse::rsv::TThreadLocalObj<type>
#define MSE_DECLARE_THREAD_LOCAL_GLOBAL(type) MSE_DECLARE_THREAD_LOCAL(type)
#define MSE_DECLARE_THREAD_LOCAL_GLOBAL_CONST(type) MSE_DECLARE_THREAD_LOCAL_CONST(type)


class CThreadLocalPtrTest1 {
Expand Down Expand Up @@ -498,7 +498,7 @@ namespace mse {

{
A a(7);
MSE_RSV_DECLARE_THREAD_LOCAL(A) thread_local_a(7);
MSE_DECLARE_THREAD_LOCAL(A) thread_local_a(7);

assert(a.b == thread_local_a.b);
A_native_ptr = &a;
Expand All @@ -521,13 +521,13 @@ namespace mse {
}

A a2 = a;
MSE_RSV_DECLARE_THREAD_LOCAL(A) thread_local_a2 = thread_local_a;
MSE_DECLARE_THREAD_LOCAL(A) thread_local_a2 = thread_local_a;
thread_local_a2 = a;
thread_local_a2 = thread_local_a;

mse::rsv::TThreadLocalFixedConstPointer<A> rcp = A_thread_local_ptr1;
mse::rsv::TThreadLocalFixedConstPointer<A> rcp2 = rcp;
MSE_RSV_DECLARE_THREAD_LOCAL_CONST(A) cthread_local_a(11);
MSE_DECLARE_THREAD_LOCAL_CONST(A) cthread_local_a(11);
mse::rsv::TThreadLocalFixedConstPointer<A> rfcp = &cthread_local_a;
}

Expand All @@ -540,7 +540,7 @@ namespace mse {

/* Polymorphic conversions that would not be supported by mse::TRegisteredPointer. */
class GE : public E {};
MSE_RSV_DECLARE_THREAD_LOCAL(GE) thread_local_gd;
MSE_DECLARE_THREAD_LOCAL(GE) thread_local_gd;
mse::rsv::TThreadLocalFixedPointer<GE> GE_thread_local_ifptr1 = &thread_local_gd;
mse::rsv::TThreadLocalFixedPointer<E> E_thread_local_ifptr5 = GE_thread_local_ifptr1;
mse::rsv::TThreadLocalFixedPointer<E> E_thread_local_fptr2(&thread_local_gd);
Expand All @@ -566,7 +566,7 @@ namespace mse {
~B() {}
};

MSE_RSV_DECLARE_THREAD_LOCAL(A) a_scpobj(5);
MSE_DECLARE_THREAD_LOCAL(A) a_scpobj(5);
int res1 = (&a_scpobj)->b;
int res2 = B::foo2(&a_scpobj);
int res3 = B::foo3(&a_scpobj);
Expand All @@ -580,7 +580,7 @@ namespace mse {

{
A a(7);
MSE_RSV_DECLARE_THREAD_LOCAL(A) thread_local_a(7);
MSE_DECLARE_THREAD_LOCAL(A) thread_local_a(7);

assert(a.b == thread_local_a.b);
A_native_ptr = &a;
Expand All @@ -603,13 +603,13 @@ namespace mse {
}

A a2 = a;
MSE_RSV_DECLARE_THREAD_LOCAL(A) thread_local_a2 = thread_local_a;
MSE_DECLARE_THREAD_LOCAL(A) thread_local_a2 = thread_local_a;
thread_local_a2 = a;
thread_local_a2 = thread_local_a;

mse::rsv::TThreadLocalFixedConstPointer<A> rcp = A_thread_local_ptr1;
mse::rsv::TThreadLocalFixedConstPointer<A> rcp2 = rcp;
MSE_RSV_DECLARE_THREAD_LOCAL_CONST(A) cthread_local_a(11);
MSE_DECLARE_THREAD_LOCAL_CONST(A) cthread_local_a(11);
mse::rsv::TThreadLocalFixedConstPointer<A> rfcp = &cthread_local_a;
}

Expand All @@ -622,7 +622,7 @@ namespace mse {

/* Polymorphic conversions that would not be supported by mse::TRegisteredPointer. */
class GE : public E {};
MSE_RSV_DECLARE_THREAD_LOCAL(GE) thread_local_gd;
MSE_DECLARE_THREAD_LOCAL(GE) thread_local_gd;
mse::rsv::TThreadLocalFixedPointer<GE> GE_thread_local_ifptr1 = &thread_local_gd;
mse::rsv::TThreadLocalFixedPointer<E> E_thread_local_ptr5(GE_thread_local_ifptr1);
mse::rsv::TThreadLocalFixedPointer<E> E_thread_local_ifptr2(&thread_local_gd);
Expand Down
20 changes: 10 additions & 10 deletions msetl_example2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class J {
}
};

MSE_RSV_DECLARE_THREAD_LOCAL_GLOBAL(mse::mstd::string) tlg_string1 = "some text";
MSE_DECLARE_THREAD_LOCAL_GLOBAL(mse::mstd::string) tlg_string1 = "some text";
MSE_RSV_DECLARE_GLOBAL_IMMUTABLE(mse::nii_string) gimm_string1 = "some text";

void msetl_example2() {
Expand Down Expand Up @@ -1030,8 +1030,8 @@ void msetl_example2() {

{
/*****************************************/
/* MSE_RSV_DECLARE_THREAD_LOCAL() */
/* & MSE_RSV_DECLARE_THREAD_LOCAL_GLOBAL() */
/* MSE_DECLARE_THREAD_LOCAL() */
/* & MSE_DECLARE_THREAD_LOCAL_GLOBAL() */
/*****************************************/

auto tlg_ptr1 = &tlg_string1;
Expand All @@ -1040,7 +1040,7 @@ void msetl_example2() {
*xs_ptr1 += "...";
std::cout << *xs_ptr1 << std::endl;

MSE_RSV_DECLARE_THREAD_LOCAL_CONST(mse::mstd::string) tlc_string2 = "abc";
MSE_DECLARE_THREAD_LOCAL_CONST(mse::mstd::string) tlc_string2 = "abc";
auto tlc_ptr2 = &tlc_string2;
auto xs_tlc_store2 = mse::make_xscope_strong_pointer_store(tlc_ptr2);
auto xs_cptr2 = xs_tlc_store2.xscope_ptr();
Expand All @@ -1049,7 +1049,7 @@ void msetl_example2() {
class CA {
public:
auto foo1() const {
MSE_RSV_DECLARE_THREAD_LOCAL(mse::mstd::string) tl_string = "abc";
MSE_DECLARE_THREAD_LOCAL(mse::mstd::string) tl_string = "abc";
/* mse::return_value() just returns its argument and ensures that it's of a (pointer) type that's safe to return. */
return mse::return_value(&tl_string);
}
Expand All @@ -1062,17 +1062,17 @@ void msetl_example2() {
}

{
/**************************************/
/* MSE_RSV_DECLARE_STATIC_IMMUTABLE() */
/******************************************/
/* MSE_DECLARE_STATIC_IMMUTABLE() */
/* & MSE_RSV_DECLARE_GLOBAL_IMMUTABLE() */
/**************************************/
/******************************************/

auto gimm_ptr1 = &gimm_string1;
auto xs_gimm_store1 = mse::make_xscope_strong_pointer_store(gimm_ptr1);
auto xs_ptr1 = xs_gimm_store1.xscope_ptr();
std::cout << *xs_ptr1 << std::endl;

MSE_RSV_DECLARE_STATIC_IMMUTABLE(mse::nii_string) simm_string2 = "abc";
MSE_DECLARE_STATIC_IMMUTABLE(mse::nii_string) simm_string2 = "abc";
auto simm_ptr2 = &simm_string2;
auto xs_simm_store2 = mse::make_xscope_strong_pointer_store(simm_ptr2);
auto xs_ptr2 = xs_simm_store2.xscope_ptr();
Expand All @@ -1081,7 +1081,7 @@ void msetl_example2() {
class CA {
public:
auto foo1() const {
MSE_RSV_DECLARE_STATIC_IMMUTABLE(mse::nii_string) simm_string = "abc";
MSE_DECLARE_STATIC_IMMUTABLE(mse::nii_string) simm_string = "abc";
/* mse::return_value() just returns its argument and ensures that it's of a (pointer) type that's safe to return. */
return mse::return_value(&simm_string);
}
Expand Down

0 comments on commit 8ff45f5

Please sign in to comment.