• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: best practices for sending data from UI to RemoteIO callback thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: best practices for sending data from UI to RemoteIO callback thread


  • Subject: Re: best practices for sending data from UI to RemoteIO callback thread
  • From: wm schauweker <email@hidden>
  • Date: Sat, 26 Mar 2011 15:34:26 -0700 (PDT)

I'm wading back in a little bit late in this thread, but I'll try to add a little bit about the thinking behind my specific design.

o The circular buffer is just an array, with separate pointers for the read and write commands.
o As I said before, the commands are currently just ints, so the buffer is an array of ints. But that is about to change to an array of Command objects:
class Command {
    int cmd_;
    int mode_;
    int minimumIntervalSecs_;
    int maximumIntervalSecs_;
}

So the buffer will change to an array of Command*

o I decided on the array and the protecting counter simply because I don't want any chance of a command writer overwriting a command (and all its details/parameters) while the reader is reading the prior command and its parameters. (I believe Paul pointed out this potential problem.)

o My guess is that the ring buffer need not hold more than two commands, but I'll just add a few more, and then I can ignore the details.

Hope this helps.

bill






From: Paul Davis <email@hidden>
To: Morgan Packard <email@hidden>
Cc: email@hidden
Sent: Sat, March 26, 2011 6:00:50 PM
Subject: Re: best practices for sending data from UI to RemoteIO callback thread

On Sat, Mar 26, 2011 at 5:57 PM, Paul Davis <email@hidden> wrote:
> On Sat, Mar 26, 2011 at 5:45 PM, Morgan Packard
> <email@hidden> wrote:
>> Great. Thanks. This had occurred to me as something that I should
>> maybe be doing, but had been told that it probably wasn't necessary.
>> Specifically, I'm triggering envelopes from my UI thread, which
>> involves resetting the "current value" member variable of the
>> envelope. I had been advised that a simple assignment of a float value
>> wasn't likely to result in threading problems. But perhaps this isn't
>> safe after all.
>
> there are two separate issues.

i missed one aspect of this: linked parameters. suppose you have a
synthesis engine with two parameters. it will *not* be safe, in
general, to rely on the atomicity of a basic variable type to update
the engine's parameters, because there is absolutely no guarantee that
the engine will not execute at a time where only one of the parameters
has been modified.

you can make this "safe" in a couple of ways:

  * make sure that the engine will never do anything wrong no matter
what the parameter values are, and interpolate changes in parameters
so that
    there are never abrupt changes
  * use lock free data structures to deliver the new values to the engine
  * not use linked parameters in your engine (this is a bit limiting :)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >best practices for sending data from UI to RemoteIO callback thread (From: Morgan Packard <email@hidden>)
 >Re: best practices for sending data from UI to RemoteIO callback thread (From: Morgan Packard <email@hidden>)
 >Re: best practices for sending data from UI to RemoteIO callback thread (From: wm schauweker <email@hidden>)
 >Re: best practices for sending data from UI to RemoteIO callback thread (From: Morgan Packard <email@hidden>)
 >Re: best practices for sending data from UI to RemoteIO callback thread (From: Paul Davis <email@hidden>)
 >Re: best practices for sending data from UI to RemoteIO callback thread (From: Morgan Packard <email@hidden>)
 >Re: best practices for sending data from UI to RemoteIO callback thread (From: Paul Davis <email@hidden>)
 >Re: best practices for sending data from UI to RemoteIO callback thread (From: Morgan Packard <email@hidden>)
 >Re: best practices for sending data from UI to RemoteIO callback thread (From: Paul Davis <email@hidden>)
 >Re: best practices for sending data from UI to RemoteIO callback thread (From: Paul Davis <email@hidden>)

  • Prev by Date: Re: best practices for sending data from UI to RemoteIO callback thread
  • Next by Date: Re: best practices for sending data from UI to RemoteIO callback thread
  • Previous by thread: Re: best practices for sending data from UI to RemoteIO callback thread
  • Next by thread: Re: best practices for sending data from UI to RemoteIO callback thread
  • Index(es):
    • Date
    • Thread