Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 173767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T13:24:05+00:00 2026-05-11T13:24:05+00:00

I have the following code and I was wondering if someone could look at

  • 0

I have the following code and I was wondering if someone could look at it for me.

I have a multi-threaded application that all share an object and operate on it. I’ve created a pointer to a certain element of it, just so I don’t have to type in the long path every time, but I’m concerned it might simply be modifying a copy of the shared object, rather than the shared object itself.

Here is the code:

RPCThread* thr = &(args->s->_shared-_>rpcThread[args->threadIndex]); ... thr->_in_use = true; ... sema_post(&(thr->_sem_result)); 

Is this valid or would this just be modifying a copy?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T13:24:06+00:00Added an answer on May 11, 2026 at 1:24 pm

    Depends on the type of member _rpcThread. If it’s simply RPCThread[] or *RPCThread then I don’t think you have a problem. If it’s a class type then you need to know the return type of its operator[]. If the relevant definition is returning a value rather than a reference, you probably have a copy.

    Unless, of course, RPCThread is a class that uses the envelope-letter idiom or implements a virtual Proxy.

    If _rpcThread is just an array, you shouldn’t have an aliasing issue here of the kind about which you’re asking.

    Here’s a good thing to check without doing much more code reading. Can you change this:

     RPCThread* thr = &(args->s->_shared->_rpcThread[args->threadIndex]); 

    to this:

     RPCThread* thr = args->s->_shared->_rpcThread + args->threadIndex; 

    without causing a compile-time error?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code and was wondering why I am not allowed to
I have the following code which is working, I was wondering if this can
I have been wondering about the following lines of code [self performSelector:@selector(myMethod) withObject:self afterDelay:1.0];
I have following code that I am compiling in a .NET 4.0 project namespace
I was wondering if someone could help with with some jquery code for doing
I have written the following code which works, but im wondering can I make
I have the following code grabbing a JSON object from github and I am
I have the following code that runs whenever you click the Start button on
I have the following code. I am wondering if there is a way to
I am wondering if someone could clarify the following from Apples Core Data documentation:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.