NotificationCenter, Server, Buffer,

View: New views
7 Messages — Rating Filter:   Alert me  

NotificationCenter, Server, Buffer,

by felix-38 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


I'd like to propose moving NotificationCenter into common and using that for Server to announce that it has created new allocators or if it has died.
This means that Buffer can register for these notifications (which are rare) rather than respond to every server.changed (which happens ever 0.4 secs).

This also means that Buffer.clearServerCaches can be cleanly removed from Server

It also means that other classes can cleanly subscribe (I wrote a BusReleasePool that needs to know)

Server.changed(\serverAdded) could also be changed to a notification.  not sure who is using this

it works, its more light weight.  cool ?

the diff:

Index: /Users/crucial/sc/SCClassLibrary/Common/Control/Server.sc
===================================================================
--- /Users/crucial/sc/SCClassLibrary/Common/Control/Server.sc (revision 7495)
+++ /Users/crucial/sc/SCClassLibrary/Common/Control/Server.sc (working copy)
@@ -37,7 +37,7 @@
 
  *initClass {
  default = this.new.blockAllocClass_(ContiguousBlockAllocator);
-// default = this.new.blockAllocClass_(PowerOfTwoAllocator);
+ //default = this.new.blockAllocClass_(PowerOfTwoAllocator);
  }
 
  *new {
@@ -134,7 +134,7 @@
 Server : Model {
  classvar <>local, <>internal, <>default, <>named, <>set, <>program;
 
- var <name, <addr, <clientID=0;
+ var <name, <>addr, <clientID=0;
  var <isLocal, <inProcess;
  var <serverRunning = false, <serverBooting=false, bootNotifyFirst=false;
  var <>options,<>latency = 0.2,<dumpMode=0, <notified=true;
@@ -188,6 +188,7 @@
  audioBusAllocator = options.blockAllocClass.new(options.numAudioBusChannels, 
  options.firstPrivateBus);
  bufferAllocator = options.blockAllocClass.new(options.numBuffers);
+ NotificationCenter.notify(this,\newAllocators);
  }
  nextNodeID {
  ^nodeAllocator.alloc
@@ -201,6 +202,7 @@
 
  *initClass {
  Class.initClassTree(ServerOptions);
+ Class.initClassTree(NotificationCenter);
  named = IdentityDictionary.new;
  set = Set.new;
  internal = Server.new(\internal, NetAddr.new);
@@ -299,7 +301,17 @@
  } {
  if (val != serverRunning) {
  serverRunning = val;
- if (serverRunning.not) { recordNode = nil };
+ if (serverRunning.not) { 
+ AppClock.sched(5.0, {
+ // still down after 5 seconds, assume server is really dead
+ // if you explicitly shut down the server then newAllocators
+ // and the \newAllocators notification will happen immediately
+ if(serverRunning.not) {
+ NotificationCenter.notify(this,\didQuit);
+ };
+ recordNode = nil;
+ })
+ };
  { this.changed(\serverRunning); }.defer;
  }
  };
@@ -409,7 +421,7 @@
 
  resetBufferAutoInfo {
  this.deprecated(thisMethod, Meta_Buffer.findRespondingMethodFor(\clearServerCaches));
- Buffer.clearServerCaches(this);
+ //Buffer.clearServerCaches(this);
  }
 
  cachedBuffersDo { |func| Buffer.cachedBuffersDo(this, func) }
@@ -460,7 +472,7 @@
  serverBooting = true;
  if(startAliveThread, { this.startAliveThread });
  this.newAllocators;
- Buffer.clearServerCaches(this);
+ //Buffer.clearServerCaches(this);
  bootNotifyFirst = true;
  this.doWhenBooted({ 
  if(notified, { 
@@ -546,7 +558,7 @@
  volume.free
  });
  this.newAllocators;
- Buffer.clearServerCaches(this);
+ //Buffer.clearServerCaches(this);
  }
 
  *quitAll {


Index: /Users/crucial/sc/SCClassLibrary/Common/Control/Buffer.sc
===================================================================
--- /Users/crucial/sc/SCClassLibrary/Common/Control/Buffer.sc (revision 7495)
+++ /Users/crucial/sc/SCClassLibrary/Common/Control/Buffer.sc (working copy)
@@ -525,9 +525,13 @@
  }
  uncache {
  serverCaches[server].removeAt(bufnum);
- // the 2 items would be the responder and server quit updater
- // thus if the size == 2, there are no cached buffers
- if(serverCaches[server].size == 2) {
+ // the 1 item would be the responder
+ // if there is more than 1 item then the rest are cached buffers
+ // else we can remove.
+ // cx: tho i don't see why its important. it will just have to be added
+ // back when the next buffer is added and the responder is removed when
+ // the server reboots
+ if(serverCaches[server].size == 1) {
  Buffer.clearServerCaches(server);
  }
  }
@@ -543,7 +547,13 @@
  buffer.queryDone;
  };
  }).add;
- serverCaches[server][\serverQuitUpdater] = Updater(server, { |svr, what|
+ NotificationCenter.register(server,\newAllocators,this,{
+ this.clearServerCaches(server);
+ });
+ // listening for server death may not be so important
+ // the most important thing was newAllocators
+ // which happens when you quit or boot the server
+ /*serverCaches[server][\serverQuitUpdater] = Updater(server, { |svr, what|
  if(what == \serverRunning and: { svr.serverRunning.not }) {
  AppClock.sched(5.0, {
  // still down after 5 seconds, assume server is really dead
@@ -552,13 +562,13 @@
  };
  })
  };
- });
+ });*/
  }
  }
  *clearServerCaches { |server|
  if(serverCaches[server].notNil) {
  serverCaches[server][\responder].remove;
- serverCaches[server][\serverQuitUpdater].remove;
+ //serverCaches[server][\serverQuitUpdater].remove;
  serverCaches.removeAt(server);
  }
  }


_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

Re: NotificationCenter, Server, Buffer,

by James Harkins-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

No objection here. NotificationCenter is really nice, I use it quite a bit.

I do use the serverAdded notification but wouldn't mind changing it.

hjh

On Apr 15, 2008, at 1:49 PM, felix wrote:

I'd like to propose moving NotificationCenter into common and using that for Server to announce that it has created new allocators or if it has died.
This means that Buffer can register for these notifications (which are rare) rather than respond to every server.changed (which happens ever 0.4 secs).

This also means that Buffer.clearServerCaches can be cleanly removed from Server

It also means that other classes can cleanly subscribe (I wrote a BusReleasePool that needs to know)

Server.changed(\serverAdded) could also be changed to a notification.  not sure who is using this

it works, its more light weight.  cool ?

the diff:

Index: /Users/crucial/sc/SCClassLibrary/Common/Control/Server.sc
===================================================================
--- /Users/crucial/sc/SCClassLibrary/Common/Control/Server.sc (revision 7495)
+++ /Users/crucial/sc/SCClassLibrary/Common/Control/Server.sc (working copy)
@@ -37,7 +37,7 @@
 
  *initClass {
  default = this.new.blockAllocClass_(ContiguousBlockAllocator);
-// default = this.new.blockAllocClass_(PowerOfTwoAllocator);
+ //default = this.new.blockAllocClass_(PowerOfTwoAllocator);
  }
 
  *new {
@@ -134,7 +134,7 @@
 Server : Model {
  classvar <>local, <>internal, <>default, <>named, <>set, <>program;
 
- var <name, <addr, <clientID=0;
+ var <name, <>addr, <clientID=0;
  var <isLocal, <inProcess;
  var <serverRunning = false, <serverBooting=false, bootNotifyFirst=false;
  var <>options,<>latency = 0.2,<dumpMode=0, <notified=true;
@@ -188,6 +188,7 @@
  audioBusAllocator = options.blockAllocClass.new(options.numAudioBusChannels, 
  options.firstPrivateBus);
  bufferAllocator = options.blockAllocClass.new(options.numBuffers);
+ NotificationCenter.notify(this,\newAllocators);
  }
  nextNodeID {
  ^nodeAllocator.alloc
@@ -201,6 +202,7 @@
 
  *initClass {
  Class.initClassTree(ServerOptions);
+ Class.initClassTree(NotificationCenter);
  named = IdentityDictionary.new;
  set = Set.new;
  internal = Server.new(\internal, NetAddr.new);
@@ -299,7 +301,17 @@
  } {
  if (val != serverRunning) {
  serverRunning = val;
- if (serverRunning.not) { recordNode = nil };
+ if (serverRunning.not) { 
+ AppClock.sched(5.0, {
+ // still down after 5 seconds, assume server is really dead
+ // if you explicitly shut down the server then newAllocators
+ // and the \newAllocators notification will happen immediately
+ if(serverRunning.not) {
+ NotificationCenter.notify(this,\didQuit);
+ };
+ recordNode = nil;
+ })
+ };
  { this.changed(\serverRunning); }.defer;
  }
  };
@@ -409,7 +421,7 @@
 
  resetBufferAutoInfo {
  this.deprecated(thisMethod, Meta_Buffer.findRespondingMethodFor(\clearServerCaches));
- Buffer.clearServerCaches(this);
+ //Buffer.clearServerCaches(this);
  }
 
  cachedBuffersDo { |func| Buffer.cachedBuffersDo(this, func) }
@@ -460,7 +472,7 @@
  serverBooting = true;
  if(startAliveThread, { this.startAliveThread });
  this.newAllocators;
- Buffer.clearServerCaches(this);
+ //Buffer.clearServerCaches(this);
  bootNotifyFirst = true;
  this.doWhenBooted({ 
  if(notified, { 
@@ -546,7 +558,7 @@
  volume.free
  });
  this.newAllocators;
- Buffer.clearServerCaches(this);
+ //Buffer.clearServerCaches(this);
  }
 
  *quitAll {


Index: /Users/crucial/sc/SCClassLibrary/Common/Control/Buffer.sc
===================================================================
--- /Users/crucial/sc/SCClassLibrary/Common/Control/Buffer.sc (revision 7495)
+++ /Users/crucial/sc/SCClassLibrary/Common/Control/Buffer.sc (working copy)
@@ -525,9 +525,13 @@
  }
  uncache {
  serverCaches[server].removeAt(bufnum);
- // the 2 items would be the responder and server quit updater
- // thus if the size == 2, there are no cached buffers
- if(serverCaches[server].size == 2) {
+ // the 1 item would be the responder
+ // if there is more than 1 item then the rest are cached buffers
+ // else we can remove.
+ // cx: tho i don't see why its important. it will just have to be added
+ // back when the next buffer is added and the responder is removed when
+ // the server reboots
+ if(serverCaches[server].size == 1) {
  Buffer.clearServerCaches(server);
  }
  }
@@ -543,7 +547,13 @@
  buffer.queryDone;
  };
  }).add;
- serverCaches[server][\serverQuitUpdater] = Updater(server, { |svr, what|
+ NotificationCenter.register(server,\newAllocators,this,{
+ this.clearServerCaches(server);
+ });
+ // listening for server death may not be so important
+ // the most important thing was newAllocators
+ // which happens when you quit or boot the server
+ /*serverCaches[server][\serverQuitUpdater] = Updater(server, { |svr, what|
  if(what == \serverRunning and: { svr.serverRunning.not }) {
  AppClock.sched(5.0, {
  // still down after 5 seconds, assume server is really dead
@@ -552,13 +562,13 @@
  };
  })
  };
- });
+ });*/
  }
  }
  *clearServerCaches { |server|
  if(serverCaches[server].notNil) {
  serverCaches[server][\responder].remove;
- serverCaches[server][\serverQuitUpdater].remove;
+ //serverCaches[server][\serverQuitUpdater].remove;
  serverCaches.removeAt(server);
  }
  }


: H. James Harkins

: jamshark70@...

: http://www.dewdrop-world.net

.::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:


"Come said the Muse,

Sing me a song no poet has yet chanted,

Sing me the universal."  -- Whitman



_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

Re: NotificationCenter, Server, Buffer,

by Dan Stowell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I haven't got time to look into NotificationCenter but in general this
sounds OK...

Dan

2008/4/15, James Harkins <jamshark70@...>:

>
> No objection here. NotificationCenter is really nice, I use it quite a bit.
>
> I do use the serverAdded notification but wouldn't mind changing it.
>
> hjh
>
> On Apr 15, 2008, at 1:49 PM, felix wrote:
>
>
> I'd like to propose moving NotificationCenter into common and using that for
> Server to announce that it has created new allocators or if it has died.
> This means that Buffer can register for these notifications (which are rare)
> rather than respond to every server.changed (which happens ever 0.4 secs).
>
> This also means that Buffer.clearServerCaches can be cleanly removed from
> Server
>
> It also means that other classes can cleanly subscribe (I wrote a
> BusReleasePool that needs to know)
>
> Server.changed(\serverAdded) could also be changed to a notification.  not
> sure who is using this
>
> it works, its more light weight.  cool ?
>
> the diff:
>
>
> Index:
> /Users/crucial/sc/SCClassLibrary/Common/Control/Server.sc
> ===================================================================
> ---
> /Users/crucial/sc/SCClassLibrary/Common/Control/Server.sc
> (revision 7495)
> +++
> /Users/crucial/sc/SCClassLibrary/Common/Control/Server.sc
> (working copy)
> @@ -37,7 +37,7 @@
>
>   *initClass {
>   default =
> this.new.blockAllocClass_(ContiguousBlockAllocator);
> -// default =
> this.new.blockAllocClass_(PowerOfTwoAllocator);
> + //default =
> this.new.blockAllocClass_(PowerOfTwoAllocator);
>   }
>
>   *new {
> @@ -134,7 +134,7 @@
>  Server : Model {
>   classvar <>local, <>internal, <>default, <>named, <>set, <>program;
>
> - var <name, <addr, <clientID=0;
> + var <name, <>addr, <clientID=0;
>   var <isLocal, <inProcess;
>   var <serverRunning = false, <serverBooting=false, bootNotifyFirst=false;
>   var <>options,<>latency = 0.2,<dumpMode=0, <notified=true;
> @@ -188,6 +188,7 @@
>   audioBusAllocator =
> options.blockAllocClass.new(options.numAudioBusChannels,
>   options.firstPrivateBus);
>   bufferAllocator =
> options.blockAllocClass.new(options.numBuffers);
> + NotificationCenter.notify(this,\newAllocators);
>   }
>   nextNodeID {
>   ^nodeAllocator.alloc
> @@ -201,6 +202,7 @@
>
>   *initClass {
>   Class.initClassTree(ServerOptions);
> + Class.initClassTree(NotificationCenter);
>   named = IdentityDictionary.new;
>   set = Set.new;
>   internal = Server.new(\internal, NetAddr.new);
> @@ -299,7 +301,17 @@
>   } {
>   if (val != serverRunning) {
>   serverRunning = val;
> - if (serverRunning.not) { recordNode = nil };
> + if (serverRunning.not) {
> + AppClock.sched(5.0, {
> + // still down after 5 seconds, assume server is really dead
> + // if you explicitly shut down the server then newAllocators
> + // and the \newAllocators notification will happen immediately
> + if(serverRunning.not) {
> + NotificationCenter.notify(this,\didQuit);
> + };
> + recordNode = nil;
> + })
> + };
>   { this.changed(\serverRunning); }.defer;
>   }
>   };
> @@ -409,7 +421,7 @@
>
>   resetBufferAutoInfo {
>   this.deprecated(thisMethod,
> Meta_Buffer.findRespondingMethodFor(\clearServerCaches));
> - Buffer.clearServerCaches(this);
> + //Buffer.clearServerCaches(this);
>   }
>
>   cachedBuffersDo { |func| Buffer.cachedBuffersDo(this, func) }
> @@ -460,7 +472,7 @@
>   serverBooting = true;
>   if(startAliveThread, { this.startAliveThread });
>   this.newAllocators;
> - Buffer.clearServerCaches(this);
> + //Buffer.clearServerCaches(this);
>   bootNotifyFirst = true;
>   this.doWhenBooted({
>   if(notified, {
> @@ -546,7 +558,7 @@
>   volume.free
>   });
>   this.newAllocators;
> - Buffer.clearServerCaches(this);
> + //Buffer.clearServerCaches(this);
>   }
>
>   *quitAll {
>
>
>
> Index:
> /Users/crucial/sc/SCClassLibrary/Common/Control/Buffer.sc
> ===================================================================
> ---
> /Users/crucial/sc/SCClassLibrary/Common/Control/Buffer.sc
> (revision 7495)
> +++
> /Users/crucial/sc/SCClassLibrary/Common/Control/Buffer.sc
> (working copy)
> @@ -525,9 +525,13 @@
>   }
>   uncache {
>   serverCaches[server].removeAt(bufnum);
> - // the 2 items would be the responder and server quit updater
> - // thus if the size == 2, there are no cached buffers
> - if(serverCaches[server].size == 2) {
> + // the 1 item would be the responder
> + // if there is more than 1 item then the rest are cached buffers
> + // else we can remove.
> + // cx: tho i don't see why its important. it will just have to be added
> + // back when the next buffer is added and the responder is removed when
> + // the server reboots
> + if(serverCaches[server].size == 1) {
>   Buffer.clearServerCaches(server);
>    }
>   }
> @@ -543,7 +547,13 @@
>   buffer.queryDone;
>   };
>   }).add;
> - serverCaches[server][\serverQuitUpdater] =
> Updater(server, { |svr, what|
> + NotificationCenter.register(server,\newAllocators,this,{
> + this.clearServerCaches(server);
> + });
> + // listening for server death may not be so important
> + // the most important thing was newAllocators
> + // which happens when you quit or boot the server
> + /*serverCaches[server][\serverQuitUpdater] =
> Updater(server, { |svr, what|
>   if(what == \serverRunning and: { svr.serverRunning.not }) {
>   AppClock.sched(5.0, {
>   // still down after 5 seconds, assume server is really dead
> @@ -552,13 +562,13 @@
>   };
>   })
>   };
> - });
> + });*/
>   }
>   }
>   *clearServerCaches { |server|
>   if(serverCaches[server].notNil) {
>   serverCaches[server][\responder].remove;
> - serverCaches[server][\serverQuitUpdater].remove;
> + //serverCaches[server][\serverQuitUpdater].remove;
>   serverCaches.removeAt(server);
>   }
>   }
>
>
>
>
>
> : H. James Harkins
>
> : jamshark70@...
>
> : http://www.dewdrop-world.net
>
> .::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:
>
>
>
>
> "Come said the Muse,
>
> Sing me a song no poet has yet chanted,
>
> Sing me the universal."  -- Whitman
>
> _______________________________________________
>  Sc-devel mailing list
>  Sc-devel@...
>  http://lists.create.ucsb.edu/mailman/listinfo/sc-devel
>
>


--
http://www.mcld.co.uk
_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

Re: NotificationCenter, Server, Buffer,

by LFSaw :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

looks nice (from relatively far away, though; no time to look in more  
detail on it, yet)

till

On 16.04.2008, at 10:51, Dan Stowell wrote:

> I haven't got time to look into NotificationCenter but in general this
> sounds OK...
>
> Dan
>
> 2008/4/15, James Harkins <jamshark70@...>:
>>
>> No objection here. NotificationCenter is really nice, I use it  
>> quite a bit.
>>
>> I do use the serverAdded notification but wouldn't mind changing it.
>>
>> hjh
>>
>> On Apr 15, 2008, at 1:49 PM, felix wrote:
>>
>>
>> I'd like to propose moving NotificationCenter into common and using  
>> that for
>> Server to announce that it has created new allocators or if it has  
>> died.
>> This means that Buffer can register for these notifications (which  
>> are rare)
>> rather than respond to every server.changed (which happens ever 0.4  
>> secs).
>>
>> This also means that Buffer.clearServerCaches can be cleanly  
>> removed from
>> Server
>>
>> It also means that other classes can cleanly subscribe (I wrote a
>> BusReleasePool that needs to know)
>>
>> Server.changed(\serverAdded) could also be changed to a  
>> notification.  not
>> sure who is using this
>>
>> it works, its more light weight.  cool ?
>>
>> the diff:
>>
>>
>> Index:
>> /Users/crucial/sc/SCClassLibrary/Common/Control/Server.sc
>> ===================================================================
>> ---
>> /Users/crucial/sc/SCClassLibrary/Common/Control/Server.sc
>> (revision 7495)
>> +++
>> /Users/crucial/sc/SCClassLibrary/Common/Control/Server.sc
>> (working copy)
>> @@ -37,7 +37,7 @@
>>
>>  *initClass {
>>  default =
>> this.new.blockAllocClass_(ContiguousBlockAllocator);
>> -// default =
>> this.new.blockAllocClass_(PowerOfTwoAllocator);
>> + //default =
>> this.new.blockAllocClass_(PowerOfTwoAllocator);
>>  }
>>
>>  *new {
>> @@ -134,7 +134,7 @@
>> Server : Model {
>>  classvar <>local, <>internal, <>default, <>named, <>set, <>program;
>>
>> - var <name, <addr, <clientID=0;
>> + var <name, <>addr, <clientID=0;
>>  var <isLocal, <inProcess;
>>  var <serverRunning = false, <serverBooting=false,  
>> bootNotifyFirst=false;
>>  var <>options,<>latency = 0.2,<dumpMode=0, <notified=true;
>> @@ -188,6 +188,7 @@
>>  audioBusAllocator =
>> options.blockAllocClass.new(options.numAudioBusChannels,
>>  options.firstPrivateBus);
>>  bufferAllocator =
>> options.blockAllocClass.new(options.numBuffers);
>> + NotificationCenter.notify(this,\newAllocators);
>>  }
>>  nextNodeID {
>>  ^nodeAllocator.alloc
>> @@ -201,6 +202,7 @@
>>
>>  *initClass {
>>  Class.initClassTree(ServerOptions);
>> + Class.initClassTree(NotificationCenter);
>>  named = IdentityDictionary.new;
>>  set = Set.new;
>>  internal = Server.new(\internal, NetAddr.new);
>> @@ -299,7 +301,17 @@
>>  } {
>>  if (val != serverRunning) {
>>  serverRunning = val;
>> - if (serverRunning.not) { recordNode = nil };
>> + if (serverRunning.not) {
>> + AppClock.sched(5.0, {
>> + // still down after 5 seconds, assume server is really dead
>> + // if you explicitly shut down the server then newAllocators
>> + // and the \newAllocators notification will happen immediately
>> + if(serverRunning.not) {
>> + NotificationCenter.notify(this,\didQuit);
>> + };
>> + recordNode = nil;
>> + })
>> + };
>>  { this.changed(\serverRunning); }.defer;
>>  }
>>  };
>> @@ -409,7 +421,7 @@
>>
>>  resetBufferAutoInfo {
>>  this.deprecated(thisMethod,
>> Meta_Buffer.findRespondingMethodFor(\clearServerCaches));
>> - Buffer.clearServerCaches(this);
>> + //Buffer.clearServerCaches(this);
>>  }
>>
>>  cachedBuffersDo { |func| Buffer.cachedBuffersDo(this, func) }
>> @@ -460,7 +472,7 @@
>>  serverBooting = true;
>>  if(startAliveThread, { this.startAliveThread });
>>  this.newAllocators;
>> - Buffer.clearServerCaches(this);
>> + //Buffer.clearServerCaches(this);
>>  bootNotifyFirst = true;
>>  this.doWhenBooted({
>>  if(notified, {
>> @@ -546,7 +558,7 @@
>>  volume.free
>>  });
>>  this.newAllocators;
>> - Buffer.clearServerCaches(this);
>> + //Buffer.clearServerCaches(this);
>>  }
>>
>>  *quitAll {
>>
>>
>>
>> Index:
>> /Users/crucial/sc/SCClassLibrary/Common/Control/Buffer.sc
>> ===================================================================
>> ---
>> /Users/crucial/sc/SCClassLibrary/Common/Control/Buffer.sc
>> (revision 7495)
>> +++
>> /Users/crucial/sc/SCClassLibrary/Common/Control/Buffer.sc
>> (working copy)
>> @@ -525,9 +525,13 @@
>>  }
>>  uncache {
>>  serverCaches[server].removeAt(bufnum);
>> - // the 2 items would be the responder and server quit updater
>> - // thus if the size == 2, there are no cached buffers
>> - if(serverCaches[server].size == 2) {
>> + // the 1 item would be the responder
>> + // if there is more than 1 item then the rest are cached buffers
>> + // else we can remove.
>> + // cx: tho i don't see why its important. it will just have to be  
>> added
>> + // back when the next buffer is added and the responder is  
>> removed when
>> + // the server reboots
>> + if(serverCaches[server].size == 1) {
>>  Buffer.clearServerCaches(server);
>>   }
>>  }
>> @@ -543,7 +547,13 @@
>>  buffer.queryDone;
>>  };
>>  }).add;
>> - serverCaches[server][\serverQuitUpdater] =
>> Updater(server, { |svr, what|
>> + NotificationCenter.register(server,\newAllocators,this,{
>> + this.clearServerCaches(server);
>> + });
>> + // listening for server death may not be so important
>> + // the most important thing was newAllocators
>> + // which happens when you quit or boot the server
>> + /*serverCaches[server][\serverQuitUpdater] =
>> Updater(server, { |svr, what|
>>  if(what == \serverRunning and: { svr.serverRunning.not }) {
>>  AppClock.sched(5.0, {
>>  // still down after 5 seconds, assume server is really dead
>> @@ -552,13 +562,13 @@
>>  };
>>  })
>>  };
>> - });
>> + });*/
>>  }
>>  }
>>  *clearServerCaches { |server|
>>  if(serverCaches[server].notNil) {
>>  serverCaches[server][\responder].remove;
>> - serverCaches[server][\serverQuitUpdater].remove;
>> + //serverCaches[server][\serverQuitUpdater].remove;
>>  serverCaches.removeAt(server);
>>  }
>>  }
>>
>>
>>
>>
>>
>> : H. James Harkins
>>
>> : jamshark70@...
>>
>> : http://www.dewdrop-world.net
>>
>> .::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:
>>
>>
>>
>>
>> "Come said the Muse,
>>
>> Sing me a song no poet has yet chanted,
>>
>> Sing me the universal."  -- Whitman
>>
>> _______________________________________________
>> Sc-devel mailing list
>> Sc-devel@...
>> http://lists.create.ucsb.edu/mailman/listinfo/sc-devel
>>
>>
>
>
> --
> http://www.mcld.co.uk
> _______________________________________________
> Sc-devel mailing list
> Sc-devel@...
> http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

Re: NotificationCenter, Server, Buffer,

by John Glover-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

This change to Server.sc gives me the following error in windows, latest svn.

ERROR: Message 'at' not understood.
RECEIVER:
   nil
ARGS:
Instance of Server {    (03582F30, gc=0C, fmt=00, flg=00, set=06)
  instance variables [42]
    dependants : nil
    name : Symbol 'localhost'
    addr : instance of NetAddr (03582EF0, size=4, set=2)
    clientID : Integer 0
    isLocal : true
    inProcess : false
    serverRunning : false
    serverBooting : false
    bootNotifyFirst : false
    options : instance of ServerOptions (03583150, size=23, set=5)
    latency : Float 0.2   3FC99999 9999999A
    dumpMode : Integer 0
    notified : true
    nodeAllocator : instance of NodeIDAllocator (035824D0, size=6, set=3)
    controlBusAllocator : instance of ContiguousBlockAllocator
(03581940, size=5, set=3)
    audioBusAllocator : instance of ContiguousBlockAllocator
(03581270, size=5, set=3)
    bufferAllocator : instance of ContiguousBlockAllocator (03580780,
size=5, set=3)
    syncThread : nil
    syncTasks : nil
    numUGens : Integer 0
    numSynths : Integer 0
    numGroups : Integer 0
    numSynthDefs : Integer 0
    avgCPU : nil
    peakCPU : nil
    sampleRate : nil
    actualSampleRate : nil
    alive : false
    booting : false
    aliveThread : nil
    aliveThreadPeriod : Float 0.7   3FE66666 66666666
    statusWatcher : nil
    tree : nil
    window : nil
    scopeWindow : nil
    emacsbuf : nil
    recordBuf : nil
    recordNode : nil
    recHeaderFormat : "aiff"
    recSampleFormat : "float"
    recChannels : Integer 2
    volume : nil
}
   Symbol 'newAllocators'
CALL STACK:
        DoesNotUnderstandError:reportError   0357FEA0
                arg this = <instance of DoesNotUnderstandError>
        Nil:handleError   0357FDB0
                arg this = nil
                arg error = <instance of DoesNotUnderstandError>
        Thread:handleError   0357F800
                arg this = <instance of Thread>
                arg error = <instance of DoesNotUnderstandError>
        Object:throw   0357F740
                arg this = <instance of DoesNotUnderstandError>
        Object:doesNotUnderstand   0357FCC0
                arg this = nil
                arg selector = 'at'
                arg args = [*2]
        Meta_NotificationCenter:notify   0357F500
                arg this = class NotificationCenter
                arg object = <instance of Server>
                arg message = 'newAllocators'
                arg args = nil
        Server:newAllocators   03580390
                arg this = <instance of Server>
        Server:init   0357F600
                arg this = <instance of Server>
                arg argName = 'localhost'
                arg argAddr = <instance of NetAddr>
                arg argOptions = nil
                arg argClientID = 0
        Meta_Server:initClass   03580B10
                arg this = class Server
        Meta_Class:initClassTree   035809C0
                arg this = class Class
                arg aClass = class Server
                var implementsInitClass = nil
        ArrayedCollection:do   03580720
                arg this = [*2]
                arg function = <instance of Function>
                var i = 1
        Meta_Class:initClassTree   03580660
                arg this = class Class
                arg aClass = class Model
                var implementsInitClass = nil
        ArrayedCollection:do   0357FF60
                arg this = [*319]
                arg function = <instance of Function>
                var i = 3
        Meta_Class:initClassTree   0357FD50
                arg this = class Class
                arg aClass = class Object
                var implementsInitClass = nil
        Process:startup   0357F3C0
                arg this = <instance of Main>
                var time = 1210415898.28125
        Main:startup   0357F360
                arg this = <instance of Main>




John

2008/4/16 LFSaw <lfsaw@...>:

> looks nice (from relatively far away, though; no time to look in more
> detail on it, yet)
>
> till
>
> On 16.04.2008, at 10:51, Dan Stowell wrote:
>> I haven't got time to look into NotificationCenter but in general this
>> sounds OK...
>>
>> Dan
>>
>> 2008/4/15, James Harkins <jamshark70@...>:
>>>
>>> No objection here. NotificationCenter is really nice, I use it
>>> quite a bit.
>>>
>>> I do use the serverAdded notification but wouldn't mind changing it.
>>>
>>> hjh
>>>
>>> On Apr 15, 2008, at 1:49 PM, felix wrote:
>>>
>>>
>>> I'd like to propose moving NotificationCenter into common and using
>>> that for
>>> Server to announce that it has created new allocators or if it has
>>> died.
>>> This means that Buffer can register for these notifications (which
>>> are rare)
>>> rather than respond to every server.changed (which happens ever 0.4
>>> secs).
>>>
>>> This also means that Buffer.clearServerCaches can be cleanly
>>> removed from
>>> Server
>>>
>>> It also means that other classes can cleanly subscribe (I wrote a
>>> BusReleasePool that needs to know)
>>>
>>> Server.changed(\serverAdded) could also be changed to a
>>> notification.  not
>>> sure who is using this
>>>
>>> it works, its more light weight.  cool ?
>>>
>>> the diff:
>>>
>>>
>>> Index:
>>> /Users/crucial/sc/SCClassLibrary/Common/Control/Server.sc
>>> ===================================================================
>>> ---
>>> /Users/crucial/sc/SCClassLibrary/Common/Control/Server.sc
>>> (revision 7495)
>>> +++
>>> /Users/crucial/sc/SCClassLibrary/Common/Control/Server.sc
>>> (working copy)
>>> @@ -37,7 +37,7 @@
>>>
>>>  *initClass {
>>>  default =
>>> this.new.blockAllocClass_(ContiguousBlockAllocator);
>>> -// default =
>>> this.new.blockAllocClass_(PowerOfTwoAllocator);
>>> + //default =
>>> this.new.blockAllocClass_(PowerOfTwoAllocator);
>>>  }
>>>
>>>  *new {
>>> @@ -134,7 +134,7 @@
>>> Server : Model {
>>>  classvar <>local, <>internal, <>default, <>named, <>set, <>program;
>>>
>>> - var <name, <addr, <clientID=0;
>>> + var <name, <>addr, <clientID=0;
>>>  var <isLocal, <inProcess;
>>>  var <serverRunning = false, <serverBooting=false,
>>> bootNotifyFirst=false;
>>>  var <>options,<>latency = 0.2,<dumpMode=0, <notified=true;
>>> @@ -188,6 +188,7 @@
>>>  audioBusAllocator =
>>> options.blockAllocClass.new(options.numAudioBusChannels,
>>>  options.firstPrivateBus);
>>>  bufferAllocator =
>>> options.blockAllocClass.new(options.numBuffers);
>>> + NotificationCenter.notify(this,\newAllocators);
>>>  }
>>>  nextNodeID {
>>>  ^nodeAllocator.alloc
>>> @@ -201,6 +202,7 @@
>>>
>>>  *initClass {
>>>  Class.initClassTree(ServerOptions);
>>> + Class.initClassTree(NotificationCenter);
>>>  named = IdentityDictionary.new;
>>>  set = Set.new;
>>>  internal = Server.new(\internal, NetAddr.new);
>>> @@ -299,7 +301,17 @@
>>>  } {
>>>  if (val != serverRunning) {
>>>  serverRunning = val;
>>> - if (serverRunning.not) { recordNode = nil };
>>> + if (serverRunning.not) {
>>> + AppClock.sched(5.0, {
>>> + // still down after 5 seconds, assume server is really dead
>>> + // if you explicitly shut down the server then newAllocators
>>> + // and the \newAllocators notification will happen immediately
>>> + if(serverRunning.not) {
>>> + NotificationCenter.notify(this,\didQuit);
>>> + };
>>> + recordNode = nil;
>>> + })
>>> + };
>>>  { this.changed(\serverRunning); }.defer;
>>>  }
>>>  };
>>> @@ -409,7 +421,7 @@
>>>
>>>  resetBufferAutoInfo {
>>>  this.deprecated(thisMethod,
>>> Meta_Buffer.findRespondingMethodFor(\clearServerCaches));
>>> - Buffer.clearServerCaches(this);
>>> + //Buffer.clearServerCaches(this);
>>>  }
>>>
>>>  cachedBuffersDo { |func| Buffer.cachedBuffersDo(this, func) }
>>> @@ -460,7 +472,7 @@
>>>  serverBooting = true;
>>>  if(startAliveThread, { this.startAliveThread });
>>>  this.newAllocators;
>>> - Buffer.clearServerCaches(this);
>>> + //Buffer.clearServerCaches(this);
>>>  bootNotifyFirst = true;
>>>  this.doWhenBooted({
>>>  if(notified, {
>>> @@ -546,7 +558,7 @@
>>>  volume.free
>>>  });
>>>  this.newAllocators;
>>> - Buffer.clearServerCaches(this);
>>> + //Buffer.clearServerCaches(this);
>>>  }
>>>
>>>  *quitAll {
>>>
>>>
>>>
>>> Index:
>>> /Users/crucial/sc/SCClassLibrary/Common/Control/Buffer.sc
>>> ===================================================================
>>> ---
>>> /Users/crucial/sc/SCClassLibrary/Common/Control/Buffer.sc
>>> (revision 7495)
>>> +++
>>> /Users/crucial/sc/SCClassLibrary/Common/Control/Buffer.sc
>>> (working copy)
>>> @@ -525,9 +525,13 @@
>>>  }
>>>  uncache {
>>>  serverCaches[server].removeAt(bufnum);
>>> - // the 2 items would be the responder and server quit updater
>>> - // thus if the size == 2, there are no cached buffers
>>> - if(serverCaches[server].size == 2) {
>>> + // the 1 item would be the responder
>>> + // if there is more than 1 item then the rest are cached buffers
>>> + // else we can remove.
>>> + // cx: tho i don't see why its important. it will just have to be
>>> added
>>> + // back when the next buffer is added and the responder is
>>> removed when
>>> + // the server reboots
>>> + if(serverCaches[server].size == 1) {
>>>  Buffer.clearServerCaches(server);
>>>   }
>>>  }
>>> @@ -543,7 +547,13 @@
>>>  buffer.queryDone;
>>>  };
>>>  }).add;
>>> - serverCaches[server][\serverQuitUpdater] =
>>> Updater(server, { |svr, what|
>>> + NotificationCenter.register(server,\newAllocators,this,{
>>> + this.clearServerCaches(server);
>>> + });
>>> + // listening for server death may not be so important
>>> + // the most important thing was newAllocators
>>> + // which happens when you quit or boot the server
>>> + /*serverCaches[server][\serverQuitUpdater] =
>>> Updater(server, { |svr, what|
>>>  if(what == \serverRunning and: { svr.serverRunning.not }) {
>>>  AppClock.sched(5.0, {
>>>  // still down after 5 seconds, assume server is really dead
>>> @@ -552,13 +562,13 @@
>>>  };
>>>  })
>>>  };
>>> - });
>>> + });*/
>>>  }
>>>  }
>>>  *clearServerCaches { |server|
>>>  if(serverCaches[server].notNil) {
>>>  serverCaches[server][\responder].remove;
>>> - serverCaches[server][\serverQuitUpdater].remove;
>>> + //serverCaches[server][\serverQuitUpdater].remove;
>>>  serverCaches.removeAt(server);
>>>  }
>>>  }
>>>
>>>
>>>
>>>
>>>
>>> : H. James Harkins
>>>
>>> : jamshark70@...
>>>
>>> : http://www.dewdrop-world.net
>>>
>>> .::!:.:.......:.::........:..!.::.::...:..:...:.:.:.:..:
>>>
>>>
>>>
>>>
>>> "Come said the Muse,
>>>
>>> Sing me a song no poet has yet chanted,
>>>
>>> Sing me the universal."  -- Whitman
>>>
>>> _______________________________________________
>>> Sc-devel mailing list
>>> Sc-devel@...
>>> http://lists.create.ucsb.edu/mailman/listinfo/sc-devel
>>>
>>>
>>
>>
>> --
>> http://www.mcld.co.uk
>> _______________________________________________
>> Sc-devel mailing list
>> Sc-devel@...
>> http://lists.create.ucsb.edu/mailman/listinfo/sc-devel
>
> _______________________________________________
> Sc-devel mailing list
> Sc-devel@...
> http://lists.create.ucsb.edu/mailman/listinfo/sc-devel
>
_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

Re: NotificationCenter, Server, Buffer,

by felix-38 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

if so, then something illogical is in place.

*initClass {

Class.initClassTree(ServerOptions);

Class.initClassTree(NotificationCenter); // <- initialised here

named = IdentityDictionary.new;

set = Set.new;

internal = Server.new(\internal, NetAddr.new); // <- creating here

                     // then doing newAllocators



so it suggests that NotificationCenter failed to initialize.

is your copy of that up to date ?


is your entire library up to date ?


default = local = Server.new(\localhost, NetAddr("127.0.0.1", 57110));

program = "cd " ++ String.scDir.quote ++ "; ./scsynth";

}




On Sat, May 10, 2008 at 12:41 PM, John Glover <glover.john@...> wrote:
Hello,

This change to Server.sc gives me the following error in windows, latest svn.

ERROR: Message 'at' not understood.
RECEIVER:
  nil
ARGS:
Instance of Server {    (03582F30, gc=0C, fmt=00, flg=00, set=06)
 instance variables [42]
   dependants : nil
   name : Symbol 'localhost'
   addr : instance of NetAddr (03582EF0, size=4, set=2)
   clientID : Integer 0
   isLocal : true
   inProcess : false
   serverRunning : false
   serverBooting : false
   bootNotifyFirst : false
   options : instance of ServerOptions (03583150, size=23, set=5)
   latency : Float 0.2   3FC99999 9999999A
   dumpMode : Integer 0
   notified : true
   nodeAllocator : instance of NodeIDAllocator (035824D0, size=6, set=3)
   controlBusAllocator : instance of ContiguousBlockAllocator
(03581940, size=5, set=3)
   audioBusAllocator : instance of ContiguousBlockAllocator
(03581270, size=5, set=3)
   bufferAllocator : instance of ContiguousBlockAllocator (03580780,
size=5, set=3)
   syncThread : nil
   syncTasks : nil
   numUGens : Integer 0
   numSynths : Integer 0
   numGroups : Integer 0
   numSynthDefs : Integer 0
   avgCPU : nil
   peakCPU : nil
   sampleRate : nil
   actualSampleRate : nil
   alive : false
   booting : false
   aliveThread : nil
   aliveThreadPeriod : Float 0.7   3FE66666 66666666
   statusWatcher : nil
   tree : nil
   window : nil
   scopeWindow : nil
   emacsbuf : nil
   recordBuf : nil
   recordNode : nil
   recHeaderFormat : "aiff"
   recSampleFormat : "float"
   recChannels : Integer 2
   volume : nil
}
  Symbol 'newAllocators'
CALL STACK:
       DoesNotUnderstandError:reportError   0357FEA0
               arg this = <instance of DoesNotUnderstandError>
       Nil:handleError   0357FDB0
               arg this = nil
               arg error = <instance of DoesNotUnderstandError>
       Thread:handleError   0357F800
               arg this = <instance of Thread>
               arg error = <instance of DoesNotUnderstandError>
       Object:throw   0357F740
               arg this = <instance of DoesNotUnderstandError>
       Object:doesNotUnderstand   0357FCC0
               arg this = nil
               arg selector = 'at'
               arg args = [*2]
       Meta_NotificationCenter:notify   0357F500
               arg this = class NotificationCenter
               arg object = <instance of Server>
               arg message = 'newAllocators'
               arg args = nil
       Server:newAllocators   03580390
               arg this = <instance of Server>
       Server:init   0357F600
               arg this = <instance of Server>
               arg argName = 'localhost'
               arg argAddr = <instance of NetAddr>
               arg argOptions = nil
               arg argClientID = 0
       Meta_Server:initClass   03580B10
               arg this = class Server
       Meta_Class:initClassTree   035809C0
               arg this = class Class
               arg aClass = class Server
               var implementsInitClass = nil
       ArrayedCollection:do   03580720
               arg this = [*2]
               arg function = <instance of Function>
               var i = 1
       Meta_Class:initClassTree   03580660
               arg this = class Class
               arg aClass = class Model
               var implementsInitClass = nil
       ArrayedCollection:do   0357FF60
               arg this = [*319]
               arg function = <instance of Function>
               var i = 3
       Meta_Class:initClassTree   0357FD50
               arg this = class Class
               arg aClass = class Object
               var implementsInitClass = nil
       Process:startup   0357F3C0
               arg this = <instance of Main>
               var time = 1210415898.28125
       Main:startup   0357F360
               arg this = <instance of Main>




John


_______________________________________________
Sc-devel mailing list
Sc-devel@...
http://lists.create.ucsb.edu/mailman/listinfo/sc-devel

Re: NotificationCenter, Server, Buffer,

by John Glover-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I think so, I did an update then recompiled everything, so unless
something else strange has happened.

John

2008/5/10 felix <felix@...>:

> if so, then something illogical is in place.
>
> *initClass {
>
> Class.initClassTree(ServerOptions);
>
> Class.initClassTree(NotificationCenter); // <- initialised here
>
> named = IdentityDictionary.new;
>
> set = Set.new;
>
> internal = Server.new(\internal, NetAddr.new); // <- creating here
>
>                      // then doing newAllocators
>
> so it suggests that NotificationCenter failed to initialize.
>
> is your copy of that up to date ?
>
> is your entire library up to date ?
>
> default = local = Server.new(\localhost, NetAddr("127.0.0.1", 57110));
>
> program = "cd " ++ String.scDir.quote ++ "; ./scsynth";
>
> }
>
>
> On Sat, May 10, 2008 at 12:41 PM, John Glover <glover.john@...> wrote:
>>
>> Hello,
>>
>> This change to Server.sc gives me the following error in windows, latest
>> svn.
>>
>> ERROR: Message 'at' not understood.
>> RECEIVER:
>>   nil
>> ARGS:
>> Instance of Server {    (03582F30, gc=0C, fmt=00, flg=00, set=06)
>>  instance variables [42]
>>    dependants : nil
>>    name : Symbol 'localhost'
>>    addr : instance of NetAddr (03582EF0, size=4, set=2)
>>    clientID : Integer 0
>>    isLocal : true
>>    inProcess : false
>>    serverRunning : false
>>    serverBooting : false
>>    bootNotifyFirst : false
>>    options : instance of ServerOptions (03583150, size=23, set=5)
>>    latency : Float 0.2   3FC99999 9999999A
>>    dumpMode : Integer 0
>>    notified : true
>>    nodeAllocator : instance of NodeIDAllocator (035824D0, size=6, set=3)
>>    controlBusAllocator : instance of ContiguousBlockAllocator
>> (03581940, size=5, set=3)
>>    audioBusAllocator : instance of ContiguousBlockAllocator
>> (03581270, size=5, set=3)
>>    bufferAllocator : instance of ContiguousBlockAllocator (03580780,
>> size=5, set=3)
>>    syncThread : nil
>>    syncTasks : nil
>>    numUGens : Integer 0
>>    numSynths : Integer 0
>>    numGroups : Integer 0
>>    numSynthDefs : Integer 0
>>    avgCPU : nil
>>    peakCPU : nil
>>    sampleRate : nil
>>    actualSampleRate : nil
>>    alive : false
>>    booting : false
>>    aliveThread : nil
>>    aliveThreadPeriod : Float 0.7   3FE66666 66666666
>>    statusWatcher : nil
>>    tree : nil
>>    window : nil
>>    scopeWindow : nil
>>    emacsbuf : nil
>>    recordBuf : nil
>>    recordNode : nil
>>    recHeaderFormat : "aiff"
>>    recSampleFormat : "float"
>>    recChannels : Integer 2
>>    volume : nil
>> }
>>   Symbol 'newAllocators'
>> CALL STACK:
>>        DoesNotUnderstandError:reportError   0357FEA0
>>                arg this = <instance of DoesNotUnderstandError>
>>        Nil:handleError   0357FDB0
>>                arg this = nil
>>                arg error = <instance of DoesNotUnderstandError>
>>        Thread:handleError   0357F800
>>                arg this = <instance of Thread>