Csound Csound-dev Csound-tekno Search About

[Csnd-dev] AuxAllocAsync

Date2017-01-27 18:15
FromVictor Lazzarini
Subject[Csnd-dev] AuxAllocAsync
Following Ed’s request, I’ve made an attempt to add an async allocation mechanism
for opcodes, through 

csound->AuxAllocAsync(CSOUND *, size_t,  AUXASYNC *);

which uses this

  typedef struct {
    CSOUND *csound;
    size_t nbytes;
    void *userData;
    void (*notify)(void *, AUXCH *);   
  } AUXASYNC;

so users set up their call back,

void notify(void *userData, AUXCH *new) {
  // userData is your dataspace
  // new contains the newly allocated memory
  // for you to swap with the old one
  // in a thread-safe manner 

  ...
}

then, in persistent memory, have a 

AUXASYNC  var;

then set

var.notify = notify;
var.userData = mydata;

and call 

if (csound->AuxAllocAsync(csound,nbytes,&var) != CSOUND_SUCCESS)
    csound->Warning(csound, “could not allocate asynchronously”);

In GIT now. Hopefully it works.
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel:

Date2017-01-27 20:29
FromEd Costello
SubjectRe: [Csnd-dev] AuxAllocAsync
Thanks Victor,

I’ll test this over the weekend and let you know if there’s any issues.
Cheers
Ed

> On 27 Jan 2017, at 18:15, Victor Lazzarini  wrote:
> 
> Following Ed’s request, I’ve made an attempt to add an async allocation mechanism
> for opcodes, through 
> 
> csound->AuxAllocAsync(CSOUND *, size_t,  AUXASYNC *);
> 
> which uses this
> 
>  typedef struct {
>    CSOUND *csound;
>    size_t nbytes;
>    void *userData;
>    void (*notify)(void *, AUXCH *);   
>  } AUXASYNC;
> 
> so users set up their call back,
> 
> void notify(void *userData, AUXCH *new) {
>  // userData is your dataspace
>  // new contains the newly allocated memory
>  // for you to swap with the old one
>  // in a thread-safe manner 
> 
>  ...
> }
> 
> then, in persistent memory, have a 
> 
> AUXASYNC  var;
> 
> then set
> 
> var.notify = notify;
> var.userData = mydata;
> 
> and call 
> 
> if (csound->AuxAllocAsync(csound,nbytes,&var) != CSOUND_SUCCESS)
>    csound->Warning(csound, “could not allocate asynchronously”);
> 
> In GIT now. Hopefully it works.
> ========================
> Prof. Victor Lazzarini
> Dean of Arts, Celtic Studies, and Philosophy,
> Maynooth University,
> Maynooth, Co Kildare, Ireland
> Tel: 00 353 7086936
> Fax: 00 353 1 7086952 

Date2017-01-27 20:43
FromVictor Lazzarini
SubjectRe: [Csnd-dev] AuxAllocAsync
ok, but it might need a little bit tweak. I’ll keep at it.
========================
Prof. Victor Lazzarini
Dean of Arts, Celtic Studies, and Philosophy,
Maynooth University,
Maynooth, Co Kildare, Ireland
Tel: 00 353 7086936
Fax: 00 353 1 7086952 

> On 27 Jan 2017, at 20:29, Ed Costello  wrote:
> 
> Thanks Victor,
> 
> I’ll test this over the weekend and let you know if there’s any issues.
> Cheers
> Ed
> 
>> On 27 Jan 2017, at 18:15, Victor Lazzarini  wrote:
>> 
>> Following Ed’s request, I’ve made an attempt to add an async allocation mechanism
>> for opcodes, through 
>> 
>> csound->AuxAllocAsync(CSOUND *, size_t,  AUXASYNC *);
>> 
>> which uses this
>> 
>> typedef struct {
>>   CSOUND *csound;
>>   size_t nbytes;
>>   void *userData;
>>   void (*notify)(void *, AUXCH *);   
>> } AUXASYNC;
>> 
>> so users set up their call back,
>> 
>> void notify(void *userData, AUXCH *new) {
>> // userData is your dataspace
>> // new contains the newly allocated memory
>> // for you to swap with the old one
>> // in a thread-safe manner 
>> 
>> ...
>> }
>> 
>> then, in persistent memory, have a 
>> 
>> AUXASYNC  var;
>> 
>> then set
>> 
>> var.notify = notify;
>> var.userData = mydata;
>> 
>> and call 
>> 
>> if (csound->AuxAllocAsync(csound,nbytes,&var) != CSOUND_SUCCESS)
>>   csound->Warning(csound, “could not allocate asynchronously”);
>> 
>> In GIT now. Hopefully it works.
>> ========================
>> Prof. Victor Lazzarini
>> Dean of Arts, Celtic Studies, and Philosophy,
>> Maynooth University,
>> Maynooth, Co Kildare, Ireland
>> Tel: 00 353 7086936
>> Fax: 00 3