diff options
author | Benoit Foucher <benoit@zeroc.com> | 2012-04-25 11:19:13 +0200 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2012-04-25 11:19:13 +0200 |
commit | 7e874613ff22bedf988273b51a15ab937f01169f (patch) | |
tree | 115a92a902f80fcc6252c5fac6a957ecc548b82c /cs/src/Ice/ThreadPool.cs | |
parent | Fixed copyrights (diff) | |
download | ice-7e874613ff22bedf988273b51a15ab937f01169f.tar.bz2 ice-7e874613ff22bedf988273b51a15ab937f01169f.tar.xz ice-7e874613ff22bedf988273b51a15ab937f01169f.zip |
Merged Silverlight support
Diffstat (limited to 'cs/src/Ice/ThreadPool.cs')
-rw-r--r-- | cs/src/Ice/ThreadPool.cs | 37 |
1 files changed, 25 insertions, 12 deletions
diff --git a/cs/src/Ice/ThreadPool.cs b/cs/src/Ice/ThreadPool.cs index 4b3e64f4d06..5f8175231dd 100644 --- a/cs/src/Ice/ThreadPool.cs +++ b/cs/src/Ice/ThreadPool.cs @@ -16,6 +16,7 @@ namespace IceInternal using System.Threading; public delegate void ThreadPoolWorkItem(); + public delegate void AsyncCallback(object state); internal struct ThreadPoolMessage { @@ -199,6 +200,7 @@ namespace IceInternal } _stackSize = stackSize; +#if !SILVERLIGHT _hasPriority = properties.getProperty(_prefix + ".ThreadPriority").Length > 0; _priority = IceInternal.Util.stringToThreadPriority(properties.getProperty(_prefix + ".ThreadPriority")); if(!_hasPriority) @@ -206,6 +208,7 @@ namespace IceInternal _hasPriority = properties.getProperty("Ice.ThreadPriority").Length > 0; _priority = IceInternal.Util.stringToThreadPriority(properties.getProperty("Ice.ThreadPriority")); } +#endif if(_instance.traceLevels().threadPool >= 1) { @@ -223,6 +226,7 @@ namespace IceInternal { WorkerThread thread = new WorkerThread(this, _threadPrefix + "-" + _threadIndex++); _threads.Add(thread); +#if !SILVERLIGHT if(_hasPriority) { thread.start(_priority); @@ -231,6 +235,9 @@ namespace IceInternal { thread.start(ThreadPriority.Normal); } +#else + thread.start(); +#endif } } catch(System.Exception ex) @@ -390,6 +397,7 @@ namespace IceInternal try { WorkerThread t = new WorkerThread(this, _threadPrefix + "-" + _threadIndex++); +#if !SILVERLIGHT if(_hasPriority) { t.start(_priority); @@ -398,6 +406,9 @@ namespace IceInternal { t.start(ThreadPriority.Normal); } +#else + t.start(); +#endif _threads.Add(t); } catch(System.Exception ex) @@ -665,22 +676,12 @@ namespace IceInternal public void asyncReadCallback(object state) { - IAsyncResult result = (IAsyncResult)state; - if(result.CompletedSynchronously) - { - return; - } - messageCallback(new ThreadPoolCurrent(this, (EventHandler)result.AsyncState, SocketOperation.Read)); + messageCallback(new ThreadPoolCurrent(this, (EventHandler)state, SocketOperation.Read)); } public void asyncWriteCallback(object state) { - IAsyncResult result = (IAsyncResult)state; - if(result.CompletedSynchronously) - { - return; - } - messageCallback(new ThreadPoolCurrent(this, (EventHandler)result.AsyncState, SocketOperation.Write)); + messageCallback(new ThreadPoolCurrent(this, (EventHandler)state, SocketOperation.Write)); } public void messageCallback(ThreadPoolCurrent current) @@ -736,6 +737,7 @@ namespace IceInternal _thread.Join(); } +#if !SILVERLIGHT public void start(ThreadPriority priority) { if(_threadPool._stackSize == 0) @@ -751,6 +753,15 @@ namespace IceInternal _thread.Priority = priority; _thread.Start(); } +#else + public void start() + { + _thread = new Thread(new ThreadStart(Run)); + _thread.IsBackground = true; + _thread.Name = _name; + _thread.Start(); + } +#endif public void Run() { @@ -801,8 +812,10 @@ namespace IceInternal private readonly int _sizeMax; // Maximum number of threads. private readonly int _sizeWarn; // If _inUse reaches _sizeWarn, a "low on threads" warning will be printed. private readonly bool _serialize; // True if requests need to be serialized over the connection. +#if !SILVERLIGHT private readonly ThreadPriority _priority; private readonly bool _hasPriority = false; +#endif private readonly int _serverIdleTime; private readonly int _threadIdleTime; private readonly int _stackSize; |