diff options
author | fcolin | 2007-02-01 09:54:00 +0000 |
---|---|---|
committer | fcolin | 2007-02-01 09:54:00 +0000 |
commit | 3c6db00323eeaa3d38d8cfd9ac5c2d4c1a8abb2b (patch) | |
tree | c02986183b8dc591a624e648c6b22e652589a0ef | |
parent | fdad9a4b517a3ee2cc93c1a165400ce10c061158 (diff) | |
download | ivy-csharp-3c6db00323eeaa3d38d8cfd9ac5c2d4c1a8abb2b.zip ivy-csharp-3c6db00323eeaa3d38d8cfd9ac5c2d4c1a8abb2b.tar.gz ivy-csharp-3c6db00323eeaa3d38d8cfd9ac5c2d4c1a8abb2b.tar.bz2 ivy-csharp-3c6db00323eeaa3d38d8cfd9ac5c2d4c1a8abb2b.tar.xz |
Utilisateur : Fcolin Date : 17/06/03 Heure : 18:52 Archivé dans $/EScribe/Ivy Commentaire: (vss 2)
-rw-r--r-- | CSharp/Ivy/IvyPPC/Ivy.cs | 52 |
1 files changed, 35 insertions, 17 deletions
diff --git a/CSharp/Ivy/IvyPPC/Ivy.cs b/CSharp/Ivy/IvyPPC/Ivy.cs index c681585..2ef37ae 100644 --- a/CSharp/Ivy/IvyPPC/Ivy.cs +++ b/CSharp/Ivy/IvyPPC/Ivy.cs @@ -59,9 +59,12 @@ namespace IvyBus get
{
String s = appName + " clients are: ";
- foreach (IvyClient client in clients.Values )
+ lock( clients.SyncRoot )
{
- s += client.ApplicationName + " ";
+ foreach (IvyClient client in clients.Values )
+ {
+ s += client.ApplicationName + " ";
+ }
}
return s;
}
@@ -125,7 +128,7 @@ namespace IvyBus public Ivy(String name, String message)
{
callbacks = new Hashtable();
- clients = new Hashtable();
+ clients = Hashtable.Synchronized( new Hashtable() );
regexp_out = new Hashtable();
appName = name;
ready_message = message;
@@ -222,7 +225,7 @@ namespace IvyBus ((IvyWatcher) watchers[i]).stop();
}
// stopping the remaining IvyClients
- lock(clients)
+ lock(clients.SyncRoot)
{
foreach (IvyClient c in clients.Values )
{
@@ -256,9 +259,12 @@ namespace IvyBus int count = 0;
// an alternate implementation would one sender thread per client
// instead of one for all the clients. It might be a performance issue
- foreach (IvyClient client in clients.Values )
+ lock ( clients.SyncRoot )
{
- count += client.sendMsg(message);
+ foreach (IvyClient client in clients.Values )
+ {
+ count += client.sendMsg(message);
+ }
}
return count;
}
@@ -286,12 +292,15 @@ namespace IvyBus {
// creates a new binding (regexp,callback)
Int32 key = serial++;
- regexp_out.Add( key, regexp);
- callbacks.Add( key, callback);
+ lock (regexp_out) regexp_out.Add( key, regexp);
+ lock (callback) callbacks.Add( key, callback);
// notifies the other clients this new regexp
- foreach (IvyClient c in clients.Values )
+ lock ( clients.SyncRoot )
{
- c.sendRegexp(key, regexp);
+ foreach (IvyClient c in clients.Values )
+ {
+ c.sendRegexp(key, regexp);
+ }
}
return key;
}
@@ -308,9 +317,12 @@ namespace IvyBus {
throw new IvyException("client wants to remove an unexistant regexp " + id);
}
- foreach (IvyClient c in clients.Values )
+ lock( clients.SyncRoot )
{
- c.delRegexp(id);
+ foreach (IvyClient c in clients.Values )
+ {
+ c.delRegexp(id);
+ }
}
}
@@ -370,7 +382,7 @@ namespace IvyBus */
internal void removeClient(IvyClient c)
{
- lock(clients)
+ lock( clients.SyncRoot )
{
clients.Remove(c.ClientKey);
}
@@ -411,7 +423,10 @@ namespace IvyBus if (stopped)
return ;
IvyClient client = new IvyClient(this,socket);
- clients.Add( client.ClientKey, client);
+ lock ( clients.SyncRoot )
+ {
+ clients.Add( client.ClientKey, client);
+ }
traceDebug(ClientNames);
}
}
@@ -496,10 +511,13 @@ namespace IvyBus {
if (clnt.AppPort == 0)
return false;
- foreach (IvyClient client in clients.Values )
+ lock( clients.SyncRoot )
{
- if (clnt != client && client.sameClient(clnt))
- return true;
+ foreach (IvyClient client in clients.Values )
+ {
+ if (clnt != client && client.sameClient(clnt))
+ return true;
+ }
}
return false;
}
|