You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Rush Manbert (JIRA)" <ji...@apache.org> on 2009/05/07 01:04:30 UTC

[jira] Created: (THRIFT-490) What are the intended uses for Guard and RWGuard (defined in Mutex.h)

What are the intended uses for Guard and RWGuard (defined in Mutex.h)
---------------------------------------------------------------------

                 Key: THRIFT-490
                 URL: https://issues.apache.org/jira/browse/THRIFT-490
             Project: Thrift
          Issue Type: Question
          Components: Library (C++)
    Affects Versions: 0.1
         Environment: Mac OS X 10.5.6
            Reporter: Rush Manbert


The Guard and RWGuard classes are defined much like the Synchronized class, but there are also two macros defined, Guard(m) and RWGuard(m) which cause a compile error if you try to declare a Guard or RWGuard on the stack.

To me, these look like scoped  mutex locks that would be used like this:
{
    Guard g(myMutex);
}

which is again just like the use of Synchronized.

Have I missed something? What is the intended usage for these classes? I need to know because I'm writing tests for them so I can test my Boost Mutex and ReadWriteMutex implementations.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-490) What are the intended uses for Guard and RWGuard (defined in Mutex.h)

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-490?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12706682#action_12706682 ] 

David Reiss commented on THRIFT-490:
------------------------------------

I guess it's a good thing I added the macros. :)

> What are the intended uses for Guard and RWGuard (defined in Mutex.h)
> ---------------------------------------------------------------------
>
>                 Key: THRIFT-490
>                 URL: https://issues.apache.org/jira/browse/THRIFT-490
>             Project: Thrift
>          Issue Type: Question
>          Components: Library (C++)
>    Affects Versions: 0.1
>         Environment: Mac OS X 10.5.6
>            Reporter: Rush Manbert
>             Fix For: 0.2
>
>         Attachments: 0001-THRIFT-490.-Clarify-the-comment-for-the-Guard-macro.patch
>
>
> The Guard and RWGuard classes are defined much like the Synchronized class, but there are also two macros defined, Guard(m) and RWGuard(m) which cause a compile error if you try to declare a Guard or RWGuard on the stack.
> To me, these look like scoped  mutex locks that would be used like this:
> {
>     Guard g(myMutex);
> }
> which is again just like the use of Synchronized.
> Have I missed something? What is the intended usage for these classes? I need to know because I'm writing tests for them so I can test my Boost Mutex and ReadWriteMutex implementations.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-490) What are the intended uses for Guard and RWGuard (defined in Mutex.h)

Posted by "Rush Manbert (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-490?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12706666#action_12706666 ] 

Rush Manbert commented on THRIFT-490:
-------------------------------------

The patch looks good..

What I can't believe is that in the test I had coded exactly the wrong thing, RWGuard(MyMutex) while meaning to do the right thing RWGuard g(myMutex), then couldn't see it until I read your reply. Stupid of me. Thanks.

> What are the intended uses for Guard and RWGuard (defined in Mutex.h)
> ---------------------------------------------------------------------
>
>                 Key: THRIFT-490
>                 URL: https://issues.apache.org/jira/browse/THRIFT-490
>             Project: Thrift
>          Issue Type: Question
>          Components: Library (C++)
>    Affects Versions: 0.1
>         Environment: Mac OS X 10.5.6
>            Reporter: Rush Manbert
>         Attachments: 0001-THRIFT-490.-Clarify-the-comment-for-the-Guard-macro.patch
>
>
> The Guard and RWGuard classes are defined much like the Synchronized class, but there are also two macros defined, Guard(m) and RWGuard(m) which cause a compile error if you try to declare a Guard or RWGuard on the stack.
> To me, these look like scoped  mutex locks that would be used like this:
> {
>     Guard g(myMutex);
> }
> which is again just like the use of Synchronized.
> Have I missed something? What is the intended usage for these classes? I need to know because I'm writing tests for them so I can test my Boost Mutex and ReadWriteMutex implementations.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (THRIFT-490) What are the intended uses for Guard and RWGuard (defined in Mutex.h)

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-490?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Reiss resolved THRIFT-490.
--------------------------------

       Resolution: Fixed
    Fix Version/s: 0.2

> What are the intended uses for Guard and RWGuard (defined in Mutex.h)
> ---------------------------------------------------------------------
>
>                 Key: THRIFT-490
>                 URL: https://issues.apache.org/jira/browse/THRIFT-490
>             Project: Thrift
>          Issue Type: Question
>          Components: Library (C++)
>    Affects Versions: 0.1
>         Environment: Mac OS X 10.5.6
>            Reporter: Rush Manbert
>             Fix For: 0.2
>
>         Attachments: 0001-THRIFT-490.-Clarify-the-comment-for-the-Guard-macro.patch
>
>
> The Guard and RWGuard classes are defined much like the Synchronized class, but there are also two macros defined, Guard(m) and RWGuard(m) which cause a compile error if you try to declare a Guard or RWGuard on the stack.
> To me, these look like scoped  mutex locks that would be used like this:
> {
>     Guard g(myMutex);
> }
> which is again just like the use of Synchronized.
> Have I missed something? What is the intended usage for these classes? I need to know because I'm writing tests for them so I can test my Boost Mutex and ReadWriteMutex implementations.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (THRIFT-490) What are the intended uses for Guard and RWGuard (defined in Mutex.h)

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/THRIFT-490?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

David Reiss updated THRIFT-490:
-------------------------------

    Attachment: 0001-THRIFT-490.-Clarify-the-comment-for-the-Guard-macro.patch

> What are the intended uses for Guard and RWGuard (defined in Mutex.h)
> ---------------------------------------------------------------------
>
>                 Key: THRIFT-490
>                 URL: https://issues.apache.org/jira/browse/THRIFT-490
>             Project: Thrift
>          Issue Type: Question
>          Components: Library (C++)
>    Affects Versions: 0.1
>         Environment: Mac OS X 10.5.6
>            Reporter: Rush Manbert
>         Attachments: 0001-THRIFT-490.-Clarify-the-comment-for-the-Guard-macro.patch
>
>
> The Guard and RWGuard classes are defined much like the Synchronized class, but there are also two macros defined, Guard(m) and RWGuard(m) which cause a compile error if you try to declare a Guard or RWGuard on the stack.
> To me, these look like scoped  mutex locks that would be used like this:
> {
>     Guard g(myMutex);
> }
> which is again just like the use of Synchronized.
> Have I missed something? What is the intended usage for these classes? I need to know because I'm writing tests for them so I can test my Boost Mutex and ReadWriteMutex implementations.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-490) What are the intended uses for Guard and RWGuard (defined in Mutex.h)

Posted by "Rush Manbert (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-490?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12706914#action_12706914 ] 

Rush Manbert commented on THRIFT-490:
-------------------------------------

Absolutely! Makes me wonder if Monitor.h should #define Synchronize(m) incorrect_use_of_Synchronize(m).

> What are the intended uses for Guard and RWGuard (defined in Mutex.h)
> ---------------------------------------------------------------------
>
>                 Key: THRIFT-490
>                 URL: https://issues.apache.org/jira/browse/THRIFT-490
>             Project: Thrift
>          Issue Type: Question
>          Components: Library (C++)
>    Affects Versions: 0.1
>         Environment: Mac OS X 10.5.6
>            Reporter: Rush Manbert
>             Fix For: 0.2
>
>         Attachments: 0001-THRIFT-490.-Clarify-the-comment-for-the-Guard-macro.patch
>
>
> The Guard and RWGuard classes are defined much like the Synchronized class, but there are also two macros defined, Guard(m) and RWGuard(m) which cause a compile error if you try to declare a Guard or RWGuard on the stack.
> To me, these look like scoped  mutex locks that would be used like this:
> {
>     Guard g(myMutex);
> }
> which is again just like the use of Synchronized.
> Have I missed something? What is the intended usage for these classes? I need to know because I'm writing tests for them so I can test my Boost Mutex and ReadWriteMutex implementations.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (THRIFT-490) What are the intended uses for Guard and RWGuard (defined in Mutex.h)

Posted by "David Reiss (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/THRIFT-490?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12706653#action_12706653 ] 

David Reiss commented on THRIFT-490:
------------------------------------

You've got it right.  The macros are to prevent uses like...

{code}
{
  Guard(myMutex);
  useSharedStructure();
}
{code}

which is invalid because the temporary Guard object is destroyed before the call to useSharedStructure.

> What are the intended uses for Guard and RWGuard (defined in Mutex.h)
> ---------------------------------------------------------------------
>
>                 Key: THRIFT-490
>                 URL: https://issues.apache.org/jira/browse/THRIFT-490
>             Project: Thrift
>          Issue Type: Question
>          Components: Library (C++)
>    Affects Versions: 0.1
>         Environment: Mac OS X 10.5.6
>            Reporter: Rush Manbert
>
> The Guard and RWGuard classes are defined much like the Synchronized class, but there are also two macros defined, Guard(m) and RWGuard(m) which cause a compile error if you try to declare a Guard or RWGuard on the stack.
> To me, these look like scoped  mutex locks that would be used like this:
> {
>     Guard g(myMutex);
> }
> which is again just like the use of Synchronized.
> Have I missed something? What is the intended usage for these classes? I need to know because I'm writing tests for them so I can test my Boost Mutex and ReadWriteMutex implementations.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.