[PD-dev] Proper way of storing a list in C

Giulio Moro giuliomoro at yahoo.it
Thu Dec 21 03:45:58 CET 2017


Hello,I am trying to implement a threaded equivalent of outlet_list(), which recursively copies the content of a list (symbol, argc, argv) into a ringbuffer at one end (worker thread) and retrieves them at the other end (audio thread). I have been looking through the Pd source code in and out but could not find a suitable function, except perhaps for those implemented in the [list] class, but they are not meant to be accessible from outside (static!).What is the best way of doing this?Thanks
For reference, here is some code:----------------a) this is the (working!) ringbuffer implementation I have for outlet_float:
  struct t_outletrb_float_msg {      t_outlet* outlet;      t_float f;  };
// call this from the audio thread  void outletrb_floatprocess(ring_buffer* rb)  {      while(rb_available_to_read(rb) > sizeof(struct t_outletrb_float_msg))      {          struct t_outletrb_float_msg msg;          rb_read_from_buffer(rb, (char*)&msg, sizeof(msg));          t_outlet* x = msg.outlet;          t_float f = msg.f;          outlet_float(x, f);      }  }
// call this from the worker threadvoid outletrb_float(ring_buffer* rb, t_outlet *x, t_float f)  {      struct t_outletrb_float_msg msg;      msg.outlet = x;      msg.f = f;      rb_write_to_buffer(rb, 1, (char*)&msg, sizeof(msg));  }
-------------------b) and this is the INCOMPLETE ringbuffer implementation of outlet_list:
  struct t_outletrb_list_msg {      t_outlet* outlet;      t_symbol* s;      int argc;      t_atom* argv;  }// call this from the audio thread  void outletrb_listprocess(ring_buffer* rb)  {///// retrieve the data from rb and use them for outlet_list();  }
// call this from the worker thread  void outletrb_list(ring_buffer* rb, t_outlet *x, t_symbol *s, int argc, t_atom *argv)
  {//??????? this is the function I am trying to figure out  }


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20171221/5aed4860/attachment-0001.html>


More information about the Pd-dev mailing list