summaryrefslogtreecommitdiff
path: root/csharp/src/Ice/ThreadPool.cs
diff options
context:
space:
mode:
Diffstat (limited to 'csharp/src/Ice/ThreadPool.cs')
-rw-r--r--csharp/src/Ice/ThreadPool.cs40
1 files changed, 11 insertions, 29 deletions
diff --git a/csharp/src/Ice/ThreadPool.cs b/csharp/src/Ice/ThreadPool.cs
index 450b656d98e..b5e51d7d554 100644
--- a/csharp/src/Ice/ThreadPool.cs
+++ b/csharp/src/Ice/ThreadPool.cs
@@ -39,7 +39,7 @@ namespace IceInternal
// the call on the UI thread which will then use its own synchronization
// context to execute continuations).
//
- var ctx = SynchronizationContext.Current as ThreadPoolSynchronizationContext;
+ var ctx = Current as ThreadPoolSynchronizationContext;
if(ctx != this)
{
_threadPool.dispatch(() => { d(state); }, null, false);
@@ -236,13 +236,10 @@ namespace IceInternal
stackSize = 0;
}
_stackSize = stackSize;
- _hasPriority = properties.getProperty(_prefix + ".ThreadPriority").Length > 0;
- _priority = IceInternal.Util.stringToThreadPriority(properties.getProperty(_prefix + ".ThreadPriority"));
- if(!_hasPriority)
- {
- _hasPriority = properties.getProperty("Ice.ThreadPriority").Length > 0;
- _priority = IceInternal.Util.stringToThreadPriority(properties.getProperty("Ice.ThreadPriority"));
- }
+
+ _priority = properties.getProperty(_prefix + ".ThreadPriority").Length > 0 ?
+ Util.stringToThreadPriority(properties.getProperty(_prefix + ".ThreadPriority")) :
+ Util.stringToThreadPriority(properties.getProperty("Ice.ThreadPriority"));
if(_instance.traceLevels().threadPool >= 1)
{
@@ -259,14 +256,7 @@ namespace IceInternal
for(int i = 0; i < _size; ++i)
{
WorkerThread thread = new WorkerThread(this, _threadPrefix + "-" + _threadIndex++);
- if(_hasPriority)
- {
- thread.start(_priority);
- }
- else
- {
- thread.start(ThreadPriority.Normal);
- }
+ thread.start(_priority);
_threads.Add(thread);
}
}
@@ -290,7 +280,7 @@ namespace IceInternal
return;
}
_destroyed = true;
- System.Threading.Monitor.PulseAll(this);
+ Monitor.PulseAll(this);
}
}
@@ -444,14 +434,7 @@ namespace IceInternal
try
{
WorkerThread t = new WorkerThread(this, _threadPrefix + "-" + _threadIndex++);
- if(_hasPriority)
- {
- t.start(_priority);
- }
- else
- {
- t.start(ThreadPriority.Normal);
- }
+ t.start(_priority);
_threads.Add(t);
}
catch(System.Exception ex)
@@ -525,7 +508,7 @@ namespace IceInternal
if(_threadIdleTime > 0)
{
- if(!System.Threading.Monitor.Wait(this, _threadIdleTime * 1000) && _workItems.Count == 0) // If timeout
+ if(!Monitor.Wait(this, _threadIdleTime * 1000) && _workItems.Count == 0) // If timeout
{
if(_destroyed)
{
@@ -557,7 +540,7 @@ namespace IceInternal
else
{
Debug.Assert(_serverIdleTime > 0 && _inUse == 0 && _threads.Count == 1);
- if(!System.Threading.Monitor.Wait(this, _serverIdleTime * 1000) &&
+ if(!Monitor.Wait(this, _serverIdleTime * 1000) &&
_workItems.Count == 0)
{
if(!_destroyed)
@@ -579,7 +562,7 @@ namespace IceInternal
}
else
{
- System.Threading.Monitor.Wait(this);
+ Monitor.Wait(this);
}
}
@@ -880,7 +863,6 @@ namespace IceInternal
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.
private readonly ThreadPriority _priority;
- private readonly bool _hasPriority = false;
private readonly int _serverIdleTime;
private readonly int _threadIdleTime;
private readonly int _stackSize;