summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cs/config/Make.rules.mak.cs4
-rw-r--r--cs/demo/Ice/async/WorkQueue.cs50
-rw-r--r--cs/demo/Ice/bidir/CallbackSenderI.cs64
-rw-r--r--cs/demo/Ice/compact/bidir/CallbackSenderI.cs33
-rw-r--r--cs/demo/Ice/compact/bidir/MainForm.cs1
-rw-r--r--cs/demo/Ice/compact/bidir/Prelink.bat1
-rw-r--r--cs/demo/Ice/compact/bidir/Program.cs1
-rw-r--r--cs/demo/Ice/compact/bidir/ProjSysgen.bat61
-rw-r--r--cs/demo/Ice/compact/bidir/README.txt85
-rwxr-xr-xcs/demo/Ice/compact/bidir/Resources/bidir.lnk1
-rw-r--r--cs/demo/Ice/compact/bidir/bidir.bib5
-rw-r--r--cs/demo/Ice/compact/bidir/bidir.dat2
-rw-r--r--cs/demo/Ice/compact/bidir/bidir.db0
-rw-r--r--cs/demo/Ice/compact/bidir/bidir.pbpxml2
-rw-r--r--cs/demo/Ice/compact/bidir/bidir.reg8
-rw-r--r--cs/demo/Ice/compact/bidir/postlink.bat34
-rw-r--r--cs/demo/Ice/compact/bidir/server.csproj99
-rw-r--r--cs/demo/Ice/compact/bidir/sources49
-rw-r--r--cs/demo/Ice/compact/hello/MainForm.cs5
-rw-r--r--cs/demo/Ice/compact/hello/Prelink.bat1
-rw-r--r--cs/demo/Ice/compact/hello/Program.cs2
-rw-r--r--cs/demo/Ice/compact/hello/ProjSysgen.bat61
-rw-r--r--cs/demo/Ice/compact/hello/README.txt68
-rwxr-xr-xcs/demo/Ice/compact/hello/Resources/hello.lnk1
-rw-r--r--cs/demo/Ice/compact/hello/client.csproj99
-rw-r--r--cs/demo/Ice/compact/hello/hello.bib5
-rw-r--r--cs/demo/Ice/compact/hello/hello.dat2
-rw-r--r--cs/demo/Ice/compact/hello/hello.db0
-rw-r--r--cs/demo/Ice/compact/hello/hello.pbpxml2
-rw-r--r--cs/demo/Ice/compact/hello/hello.reg8
-rw-r--r--cs/demo/Ice/compact/hello/postlink.bat34
-rw-r--r--cs/demo/Ice/compact/hello/sources48
-rw-r--r--cs/demo/Ice/multicast/DiscoverReplyI.cs44
-rw-r--r--cs/demo/Ice/properties/Server.cs10
-rw-r--r--cs/demo/Ice/session/Client.cs43
-rw-r--r--cs/demo/Ice/session/ReapThread.cs75
-rwxr-xr-xcs/demo/democf.sln38
-rw-r--r--cs/src/Glacier2/Application.cs35
-rw-r--r--cs/src/Glacier2/SessionHelper.cs22
-rw-r--r--cs/src/Ice/Application.cs167
-rw-r--r--cs/src/Ice/AsyncIOThread.cs35
-rw-r--r--cs/src/Ice/ConnectRequestHandler.cs123
-rw-r--r--cs/src/Ice/ConnectionFactory.cs206
-rw-r--r--cs/src/Ice/ConnectionI.cs285
-rw-r--r--cs/src/Ice/EndpointHostResolver.cs36
-rw-r--r--cs/src/Ice/LocatorInfo.cs36
-rw-r--r--cs/src/Ice/Makefile1
-rw-r--r--cs/src/Ice/Makefile.mak1
-rw-r--r--cs/src/Ice/Monitor.cs290
-rw-r--r--cs/src/Ice/Network.cs7
-rw-r--r--cs/src/Ice/ObjectAdapterFactory.cs83
-rw-r--r--cs/src/Ice/ObjectAdapterI.cs288
-rw-r--r--cs/src/Ice/Outgoing.cs111
-rw-r--r--cs/src/Ice/OutgoingAsync.cs186
-rw-r--r--cs/src/Ice/TcpTransceiver.cs30
-rw-r--r--cs/src/Ice/ThreadPool.cs136
-rw-r--r--cs/src/Ice/Timer.cs54
-rw-r--r--cs/src/Ice/UdpTransceiver.cs22
-rw-r--r--cs/src/IceBox/ServiceManagerI.cs63
-rw-r--r--cs/src/Makefile.mak5
-rw-r--r--cs/test/Glacier2/router/CallbackI.cs19
-rw-r--r--cs/test/Glacier2/sessionHelper/Client.cs68
-rw-r--r--cs/test/Ice/admin/TestI.cs19
-rw-r--r--cs/test/Ice/ami/AllTests.cs19
-rw-r--r--cs/test/Ice/ami/Collocated.cs2
-rw-r--r--cs/test/Ice/ami/TestI.cs26
-rw-r--r--cs/test/Ice/background/AllTests.cs26
-rw-r--r--cs/test/Ice/background/BackgroundControllerI.cs26
-rw-r--r--cs/test/Ice/binding/AllTests.cs20
-rw-r--r--cs/test/Ice/dictMapping/TwowaysAMI.cs19
-rw-r--r--cs/test/Ice/dictMapping/TwowaysNewAMI.cs19
-rw-r--r--cs/test/Ice/dispatcher/AllTests.cs20
-rw-r--r--cs/test/Ice/dispatcher/Dispatcher.cs29
-rw-r--r--cs/test/Ice/exceptions/AllTests.cs19
-rw-r--r--cs/test/Ice/exceptions/Collocated.cs8
-rw-r--r--cs/test/Ice/faultTolerance/AllTests.cs29
-rw-r--r--cs/test/Ice/hold/AllTests.cs19
-rw-r--r--cs/test/Ice/invoke/AllTests.cs21
-rw-r--r--cs/test/Ice/metrics/AllTests.cs39
-rw-r--r--cs/test/Ice/objects/Collocated.cs12
-rw-r--r--cs/test/Ice/operations/OnewaysAMI.cs19
-rw-r--r--cs/test/Ice/operations/OnewaysNewAMI.cs19
-rw-r--r--cs/test/Ice/operations/TwowaysAMI.cs19
-rw-r--r--cs/test/Ice/operations/TwowaysNewAMI.cs19
-rw-r--r--cs/test/Ice/retry/AllTests.cs19
-rw-r--r--cs/test/Ice/seqMapping/Collocated.cs11
-rw-r--r--cs/test/Ice/seqMapping/TwowaysAMI.cs19
-rw-r--r--cs/test/Ice/seqMapping/TwowaysNewAMI.cs19
-rw-r--r--cs/test/Ice/servantLocator/Collocated.cs11
-rw-r--r--cs/test/Ice/slicing/exceptions/AllTests.cs19
-rw-r--r--cs/test/Ice/slicing/objects/AllTests.cs19
-rw-r--r--cs/test/Ice/timeout/AllTests.cs19
-rw-r--r--cs/test/Ice/udp/AllTests.cs26
-rw-r--r--cs/test/IceBox/admin/TestI.cs19
94 files changed, 1006 insertions, 2978 deletions
diff --git a/cs/config/Make.rules.mak.cs b/cs/config/Make.rules.mak.cs
index e60e09c4c47..164c930a7e8 100644
--- a/cs/config/Make.rules.mak.cs
+++ b/cs/config/Make.rules.mak.cs
@@ -190,11 +190,13 @@ MCSFLAGS = $(MCSFLAGS) /reference:"$(FRAMEWORKDIR)\v2.0.50727\System.Data.dll"
MCSFLAGS = $(MCSFLAGS) /reference:"$(PROGRAMFILES)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll"
MCSFLAGS = $(MCSFLAGS) /reference:"$(PROGRAMFILES)\Reference Assemblies\Microsoft\Framework\v3.0\System.Runtime.Serialization.dll"
!elseif "$(COMPACT)" == "yes"
-NETCF_HOME = $(PROGRAMFILES)\Microsoft.NET\SDK\CompactFramework\v3.5\WindowsCE
+NETCF_HOME = $(PROGRAMFILES)\Reference Assemblies\Microsoft\Framework\WindowsEmbeddedCompact\v3.9
NETCF_REFS = "/r:$(NETCF_HOME)\mscorlib.dll" \
"/r:$(NETCF_HOME)\System.dll" \
"/r:$(NETCF_HOME)\System.Runtime.Serialization.dll"
MCSFLAGS = $(MCSFLAGS) -noconfig -nostdlib -define:COMPACT $(NETCF_REFS)
+# For testing COMPACT with regular .NET.
+#MCSFLAGS = $(MCSFLAGS) -define:COMPACT
!elseif "$(UNITY)" == "yes"
#
# You can compile against the WebPlayer assemblies by enabling the MCSFLAGS line below.
diff --git a/cs/demo/Ice/async/WorkQueue.cs b/cs/demo/Ice/async/WorkQueue.cs
index e818c9f8050..37cd4148352 100644
--- a/cs/demo/Ice/async/WorkQueue.cs
+++ b/cs/demo/Ice/async/WorkQueue.cs
@@ -33,22 +33,13 @@ public class WorkQueue
public void Run()
{
-#if COMPACT
- _m.Lock();
- try
-#else
lock(this)
-#endif
{
while(!_done)
{
if(_callbacks.Count == 0)
{
-#if COMPACT
- _m.Wait();
-#else
Monitor.Wait(this);
-#endif
}
if(_callbacks.Count != 0)
@@ -63,11 +54,7 @@ public class WorkQueue
// emulate a process that takes a significant period of
// time to complete.
//
-#if COMPACT
- _m.TimedWait(entry.delay);
-#else
Monitor.Wait(this, entry.delay);
-#endif
if(!_done)
{
@@ -86,22 +73,11 @@ public class WorkQueue
e.cb.ice_exception(new RequestCanceledException());
}
}
-#if COMPACT
- finally
- {
- _m.Unlock();
- }
-#endif
}
public void Add(AMD_Hello_sayHello cb, int delay)
{
-#if COMPACT
- _m.Lock();
- try
-#else
lock(this)
-#endif
{
if(!_done)
{
@@ -114,11 +90,7 @@ public class WorkQueue
if(_callbacks.Count == 0)
{
-#if COMPACT
- _m.Notify();
-#else
Monitor.Pulse(this);
-#endif
}
_callbacks.Add(entry);
}
@@ -130,40 +102,18 @@ public class WorkQueue
cb.ice_exception(new RequestCanceledException());
}
}
-#if COMPACT
- finally
- {
- _m.Unlock();
- }
-#endif
}
public void destroy()
{
-#if COMPACT
- _m.Lock();
- try
- {
- _done = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
- }
-#else
lock(this)
{
_done = true;
Monitor.Pulse(this);
}
-#endif
}
private ArrayList _callbacks = new ArrayList();
private bool _done = false;
private Thread thread_;
-#if COMPACT
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
-#endif
}
diff --git a/cs/demo/Ice/bidir/CallbackSenderI.cs b/cs/demo/Ice/bidir/CallbackSenderI.cs
index 8a78a622b5e..a62878ea646 100644
--- a/cs/demo/Ice/bidir/CallbackSenderI.cs
+++ b/cs/demo/Ice/bidir/CallbackSenderI.cs
@@ -22,20 +22,6 @@ class CallbackSenderI : CallbackSenderDisp_
public void destroy()
{
-#if COMPACT
- _m.Lock();
- try
- {
- System.Console.Out.WriteLine("destroying callback sender");
- _destroy = true;
-
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
- }
-#else
lock(this)
{
System.Console.Out.WriteLine("destroying callback sender");
@@ -43,26 +29,10 @@ class CallbackSenderI : CallbackSenderDisp_
System.Threading.Monitor.Pulse(this);
}
-#endif
}
public override void addClient(Ice.Identity ident, Ice.Current current)
{
-#if COMPACT
- _m.Lock();
- try
- {
- System.Console.Out.WriteLine("adding client `" + _communicator.identityToString(ident) + "'");
-
- Ice.ObjectPrx @base = current.con.createProxy(ident);
- CallbackReceiverPrx client = CallbackReceiverPrxHelper.uncheckedCast(@base);
- _clients.Add(client);
- }
- finally
- {
- _m.Unlock();
- }
-#else
lock(this)
{
System.Console.Out.WriteLine("adding client `" + _communicator.identityToString(ident) + "'");
@@ -71,7 +41,6 @@ class CallbackSenderI : CallbackSenderDisp_
CallbackReceiverPrx client = CallbackReceiverPrxHelper.uncheckedCast(@base);
_clients.Add(client);
}
-#endif
}
public void Run()
@@ -80,23 +49,6 @@ class CallbackSenderI : CallbackSenderDisp_
while(true)
{
ArrayList clients;
-#if COMPACT
- _m.Lock();
- try
- {
- _m.TimedWait(2000);
- if(_destroy)
- {
- break;
- }
-
- clients = new ArrayList(_clients);
- }
- finally
- {
- _m.Unlock();
- }
-#else
lock(this)
{
System.Threading.Monitor.Wait(this, 2000);
@@ -107,7 +59,6 @@ class CallbackSenderI : CallbackSenderDisp_
clients = new ArrayList(_clients);
}
-#endif
if(clients.Count > 0)
{
@@ -123,22 +74,10 @@ class CallbackSenderI : CallbackSenderDisp_
Console.Error.WriteLine("removing client `" +
_communicator.identityToString(c.ice_getIdentity()) + "':\n" + ex);
-#if COMPACT
- _m.Lock();
- try
- {
- _clients.Remove(c);
- }
- finally
- {
- _m.Unlock();
- }
-#else
lock(this)
{
_clients.Remove(c);
}
-#endif
}
}
}
@@ -148,7 +87,4 @@ class CallbackSenderI : CallbackSenderDisp_
private Ice.Communicator _communicator;
private bool _destroy;
private ArrayList _clients;
-#if COMPACT
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
-#endif
}
diff --git a/cs/demo/Ice/compact/bidir/CallbackSenderI.cs b/cs/demo/Ice/compact/bidir/CallbackSenderI.cs
index 594574cd55b..cce1deb1dcb 100644
--- a/cs/demo/Ice/compact/bidir/CallbackSenderI.cs
+++ b/cs/demo/Ice/compact/bidir/CallbackSenderI.cs
@@ -22,24 +22,18 @@ class CallbackSenderI : CallbackSenderDisp_
public void destroy()
{
- _m.Lock();
- try
+ lock(this)
{
System.Console.Out.WriteLine("destroying callback sender");
_destroy = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
public override void addClient(Ice.Identity ident, Ice.Current current)
{
- _m.Lock();
- try
+ lock(this)
{
System.Console.Out.WriteLine("adding client `" + _communicator.identityToString(ident) + "'");
@@ -47,10 +41,6 @@ class CallbackSenderI : CallbackSenderDisp_
CallbackReceiverPrx client = CallbackReceiverPrxHelper.uncheckedCast(@base);
_clients.Add(client);
}
- finally
- {
- _m.Unlock();
- }
}
public void Run()
@@ -59,10 +49,9 @@ class CallbackSenderI : CallbackSenderDisp_
while(true)
{
ArrayList clients;
- _m.Lock();
- try
+ lock(this)
{
- _m.TimedWait(2000);
+ System.Threading.Monitor.Wait(this, 2000);
if(_destroy)
{
break;
@@ -70,10 +59,6 @@ class CallbackSenderI : CallbackSenderDisp_
clients = new ArrayList(_clients);
}
- finally
- {
- _m.Unlock();
- }
if(clients.Count > 0)
{
@@ -88,15 +73,10 @@ class CallbackSenderI : CallbackSenderDisp_
{
Console.Error.WriteLine("removing client `" +
_communicator.identityToString(c.ice_getIdentity()) + "':\n" + ex);
- _m.Lock();
- try
+ lock(this)
{
_clients.Remove(c);
}
- finally
- {
- _m.Unlock();
- }
}
}
}
@@ -106,5 +86,4 @@ class CallbackSenderI : CallbackSenderDisp_
private Ice.Communicator _communicator;
private bool _destroy;
private ArrayList _clients;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
diff --git a/cs/demo/Ice/compact/bidir/MainForm.cs b/cs/demo/Ice/compact/bidir/MainForm.cs
index aa7a933ca0b..8896754d76f 100644
--- a/cs/demo/Ice/compact/bidir/MainForm.cs
+++ b/cs/demo/Ice/compact/bidir/MainForm.cs
@@ -8,7 +8,6 @@
// **********************************************************************
using System;
-using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
diff --git a/cs/demo/Ice/compact/bidir/Prelink.bat b/cs/demo/Ice/compact/bidir/Prelink.bat
new file mode 100644
index 00000000000..7b8fc854e72
--- /dev/null
+++ b/cs/demo/Ice/compact/bidir/Prelink.bat
@@ -0,0 +1 @@
+@REM Add pre-link commands below.
diff --git a/cs/demo/Ice/compact/bidir/Program.cs b/cs/demo/Ice/compact/bidir/Program.cs
index 0b31894d5f9..7cdf2c2f668 100644
--- a/cs/demo/Ice/compact/bidir/Program.cs
+++ b/cs/demo/Ice/compact/bidir/Program.cs
@@ -8,7 +8,6 @@
// **********************************************************************
using System;
-using System.Linq;
using System.Collections.Generic;
using System.Windows.Forms;
diff --git a/cs/demo/Ice/compact/bidir/ProjSysgen.bat b/cs/demo/Ice/compact/bidir/ProjSysgen.bat
new file mode 100644
index 00000000000..543916c9afa
--- /dev/null
+++ b/cs/demo/Ice/compact/bidir/ProjSysgen.bat
@@ -0,0 +1,61 @@
+@REM
+@REM Copyright (c) Microsoft Corporation. All rights reserved.
+@REM
+@REM
+@REM Use of this sample source code is subject to the terms of the Microsoft
+@REM license agreement under which you licensed this sample source code. If
+@REM you did not accept the terms of the license agreement, you are not
+@REM authorized to use this sample source code. For the terms of the license,
+@REM please see the license agreement between you and Microsoft or, if applicable,
+@REM see the LICENSE.RTF on your install media or the root of your tools installation.
+@REM THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
+@REM
+if /i not "%1"=="preproc" goto :Not_Preproc
+ goto :EOF
+:Not_Preproc
+if /i not "%1"=="pass1" goto :Not_Pass1
+
+ REM ==============================================================================================
+ REM
+ REM Application Builder Debugging Support
+ REM
+ REM ==============================================================================================
+ if not "%SYSGEN_APPDEBUG%"=="1" goto NoAPPDEBUG
+ set SYSGEN_DCOM=1
+ set SYSGEN_MINGDI=1
+ set SYSGEN_MINGWES=1
+ set SYSGEN_MINWMGR=1
+ set SYSGEN_MSVCP=1
+ set SYSGEN_NETWORKING=1
+ set __SYSGEN_OLEAUT32=1
+ set __SYSGEN_WWSAPI=1
+ set SYSGEN_FSDBASE=1
+ set SYSGEN_MININPUT=1
+ set SYSGEN_TOOLHELP=1
+ :NoAPPDEBUG
+
+ REM ==============================================================================================
+ REM
+ REM Remote Tools Support
+ REM
+ REM ==============================================================================================
+ if not "%SYSGEN_REMOTETOOLS%"=="1" goto NoREMOTETOOLS
+ set SYSGEN_FSDBASE=1
+ set SYSGEN_MINGDI=1
+ set SYSGEN_MINGWES=1
+ set SYSGEN_MININPUT=1
+ set SYSGEN_MINWMGR=1
+ set SYSGEN_NETWORKING=1
+ set SYSGEN_OLE=1
+ set SYSGEN_SHELL=1
+ :NoREMOTETOOLS
+
+ goto :EOF
+:Not_Pass1
+if /i not "%1"=="pass2" goto :Not_Pass2
+ goto :EOF
+:Not_Pass2
+if /i not "%1"=="report" goto :Not_Report
+ goto :EOF
+:Not_Report
+echo %0 Invalid parameter %1
diff --git a/cs/demo/Ice/compact/bidir/README.txt b/cs/demo/Ice/compact/bidir/README.txt
index 72e2da41ec8..db468cdb174 100644
--- a/cs/demo/Ice/compact/bidir/README.txt
+++ b/cs/demo/Ice/compact/bidir/README.txt
@@ -1,72 +1,65 @@
This demo shows how to write a simple C# server application using Ice
-for .NET Compact Framework (CF).
+for .NET Compact Framework (Compact 2013).
This demo requires a bidir client. You can use the C# client located
in ..\..\bidir, or you can use a client from any other language
mapping.
-You must use Visual Studio 2008 to build this server (Visual Studio
-2010 does not support for Compact Framework development). Follow these
-instructions to build and run the server:
+You must use Visual Studio 2013 to build this client. Follow these
+instructions to build and run the client:
-1) Open the project in Visual Studio 2008. This is a Smart Device
- project and therefore Visual Studio will compile it against the
- Compact Framework libraries. Furthermore, the Ice Visual Studio
- Add-in detects a Smart Device project and automatically
- configures the project to compile against the Ice for .NET CF
- DLL in <Ice installation directory>\Assemblies\cf\Ice.dll.
+1) Install Windows Embedded Compact 2013 as described below:
-2) Build the server by right-clicking on the project and choosing
- "Build".
+ http://msdn.microsoft.com/en-us/library/jj200354.aspx
-3) Start a device emulator. Select Tools -> Device Emulator Manager,
- highlight "USA Windows Mobile 5.0 Pocket PC R2 Emulator", and
- select Actions -> Connect.
+2) Setup a Virtual Test Device:
-4) In the emulator window, select File -> Configure, open the Network
- tab, and check "Enable NE2000 PCMCIA network adapter". Open the
- drop-down menu and select the appropriate network adapter, then
- press OK.
+ http://msdn.microsoft.com/en-us/library/jj200348.aspx.
- If you get an error dialog that mentions Virtual PC 2007, you will
- need to install this product to enable network access for the
- emulator. You can download Virtual PC 2007 at the link below:
+3) Create an OS:
- http://www.microsoft.com/downloads/en/details.aspx?FamilyID=04d26402-3199-48a3-afa2-2dc0b40a73b6
+ http://msdn.microsoft.com/en-us/library/jj200351.aspx
- Close the emulator, install Virtual PC 2007, and restart the
- emulator.
+ Ensure that you select "Win32 and WinForms UI Device", and ensure
+ that "Application Debugging support" and "Remote Tools Support" is
+ enabled.
-5) After successfully enabling the network adapter, you may need to
- activate the network connection. Click on the symbol resembling an
- antenna in the device's status bar and choose Connect to start the
- connection. If you wish, start Internet Explorer and verify that
- you can successfully access the Internet.
+4) Build the OS and ensure that it successfully deploys to your
+ virtual device.
-6) In Visual Studio, right-click on the project, choose Deploy, select
- the "USA Windows Mobile 5.0 Pocket PC R2 Emulator" device, and
- click Deploy. This action causes Visual Studio to install the .NET
- CF run time, the server executable, and the Ice for .NET CF run
- time in the emulator.
+5) At this point it may be useful to create a test Subproject to
+ ensure you can build and deploy executables:
-7) In the emulator, choose Start -> Programs and select File Explorer.
- Click on My Documents and choose My Device. Select Program Files,
- then select "server".
+ http://msdn.microsoft.com/en-us/library/jj200344.aspx
-8) Select "server" to start the program. Click the Start Server button
- to start the server.
+6) Select Subprojects>Add Existing Subproject. Navigate to
+ "cs/demo/Ice/compact/bidir" and select "bidir.pbpxml".
+
+ You will need to build Callback.ice with slice2cs. To do this
+ select Subprojects>bidir>Open Build Window
+
+ At the prompt enter slice2cs Callback.ice. This produces
+ Callback.cs which is built by the project.
+
+7) Select Build>Build All Subprojects.
+
+8) To run the application, go to Target>Run Programs and select
+ bidir.exe.
9) Before you can run the bidir client, you need to know the IP
- address being used by the emulator. In the emulator, choose Start
- -> Settings, select the Connections tab, click on Network Cards,
- and click on "NE2000 Compatible Ethernet Driver". Here you can find
- the device's IP address.
+ address being used by the Virtual Device. When the virtual device
+ is opened it will report the IP address
+
+ Got Response from DHCP server x.x.x.x with address y.y.y.y
+
+ The device's IP address is the y.y.y.y address.
Edit the config.client file for your bidir client and change the
following line:
CallbackSender.Proxy=sender:tcp -h localhost -p 10000
- Replace "localhost" with the IP address of the emulator.
+ Replace "localhost" with the IP address of the Virtual Device.
-10) Finally, start the bidir client.
+10) To run the application, go to Target>Run Programs and select
+ bidir.exe.
diff --git a/cs/demo/Ice/compact/bidir/Resources/bidir.lnk b/cs/demo/Ice/compact/bidir/Resources/bidir.lnk
new file mode 100755
index 00000000000..a4af63e90a2
--- /dev/null
+++ b/cs/demo/Ice/compact/bidir/Resources/bidir.lnk
@@ -0,0 +1 @@
+20#\Windows\poonose.exe \ No newline at end of file
diff --git a/cs/demo/Ice/compact/bidir/bidir.bib b/cs/demo/Ice/compact/bidir/bidir.bib
new file mode 100644
index 00000000000..0e84ec7f774
--- /dev/null
+++ b/cs/demo/Ice/compact/bidir/bidir.bib
@@ -0,0 +1,5 @@
+FILES
+; @XIPREGION IF PLATFORM_FILES_MISC
+bidir.exe $(_FLATRELEASEDIR)\bidir.exe NK U
+Ice.dll $(_FLATRELEASEDIR)\Ice.dll NK U
+; @XIPREGION ENDIF PLATFORM_FILES_MISC
diff --git a/cs/demo/Ice/compact/bidir/bidir.dat b/cs/demo/Ice/compact/bidir/bidir.dat
new file mode 100644
index 00000000000..d74a66dc357
--- /dev/null
+++ b/cs/demo/Ice/compact/bidir/bidir.dat
@@ -0,0 +1,2 @@
+Directory("\Windows"):-Directory("Start Menu")
+Directory("\Windows\Start Menu"):-File("bidir.lnk","\Windows\bidir.lnk") \ No newline at end of file
diff --git a/cs/demo/Ice/compact/bidir/bidir.db b/cs/demo/Ice/compact/bidir/bidir.db
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/cs/demo/Ice/compact/bidir/bidir.db
diff --git a/cs/demo/Ice/compact/bidir/bidir.pbpxml b/cs/demo/Ice/compact/bidir/bidir.pbpxml
new file mode 100644
index 00000000000..38e5abcc61c
--- /dev/null
+++ b/cs/demo/Ice/compact/bidir/bidir.pbpxml
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<PBProject BibFile="bidir.bib" DatFile="bidir.dat" DbFile="bidir.db" DisplayName="bidir" RegFile="bidir.reg" xmlns="urn:PBProject-schema" /> \ No newline at end of file
diff --git a/cs/demo/Ice/compact/bidir/bidir.reg b/cs/demo/Ice/compact/bidir/bidir.reg
new file mode 100644
index 00000000000..073b41794c0
--- /dev/null
+++ b/cs/demo/Ice/compact/bidir/bidir.reg
@@ -0,0 +1,8 @@
+
+;MinShell Menu Registry Entries;==============================
+
+; Run Menu for bidir
+[HKEY_LOCAL_MACHINE\Software\Compact13Tools\Shell\Minshell\bidir]
+ "App"="bidir.exe"
+ "Param"=""
+
diff --git a/cs/demo/Ice/compact/bidir/postlink.bat b/cs/demo/Ice/compact/bidir/postlink.bat
new file mode 100644
index 00000000000..6dbec96dbb5
--- /dev/null
+++ b/cs/demo/Ice/compact/bidir/postlink.bat
@@ -0,0 +1,34 @@
+
+@echo copying Content Files from Resource Files folder to Targeted Debug Directory
+copy ".\Resources\*.*" "%SG_OUTPUT_ROOT%\oak\target\%_TGTCPU%\%WINCEDEBUG%" /Y
+
+@echo copying Content Files from Resource Files folder to FlatRelease Directory
+copy ".\Resources\*.*" %_FLATRELEASEDIR% /Y
+@echo copying DLLs FlatRelease Directory
+copy "..\..\..\..\Assemblies\cf\Ice.dll" %_FLATRELEASEDIR% /Y
+
+@echo .
+@echo Building .cab file
+@echo .
+
+PUSHD
+cd %_FLATRELEASEDIR%
+IF EXIST bidir.inf (
+ cabwiz bidir.inf
+ IF EXIST bidir.cab (
+ @echo Generated .cab file: bidir.cab in FLATRELEASEDIR.
+ ) else (
+ @echo Generation of .cab file: bidir.cab failed.
+ )
+)else (
+ @echo No file bidir.inf for .cab file generation
+)
+
+POPD
+
+@echo .
+@echo Done Copying
+@echo .
+
+:SKIP
+
diff --git a/cs/demo/Ice/compact/bidir/server.csproj b/cs/demo/Ice/compact/bidir/server.csproj
deleted file mode 100644
index 2bf5a2193c0..00000000000
--- a/cs/demo/Ice/compact/bidir/server.csproj
+++ /dev/null
@@ -1,99 +0,0 @@
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{05B11482-32A1-4212-A7F8-2A135FADD164}</ProjectGuid>
- <OutputType>WinExe</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>server</RootNamespace>
- <AssemblyName>server</AssemblyName>
- <ProjectTypeGuids>{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <PlatformFamilyName>PocketPC</PlatformFamilyName>
- <PlatformID>4118C335-430C-497f-BE48-11C3316B135E</PlatformID>
- <OSVersion>5.1</OSVersion>
- <DeployDirSuffix>server</DeployDirSuffix>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <NativePlatformName>Windows Mobile 5.0 Pocket PC SDK</NativePlatformName>
- <FormFactorID>
- </FormFactorID>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>bin\Debug\</OutputPath>
- <DefineConstants>TRACE;DEBUG;PocketPC COMPACT</DefineConstants>
- <NoStdLib>true</NoStdLib>
- <NoConfig>true</NoConfig>
- <ErrorReport>prompt</ErrorReport>
- <FileAlignment>512</FileAlignment>
- <WarningLevel>4</WarningLevel>
- <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>bin\Release\</OutputPath>
- <DefineConstants>TRACE;$(PlatformFamilyName)</DefineConstants>
- <NoStdLib>true</NoStdLib>
- <NoConfig>true</NoConfig>
- <ErrorReport>prompt</ErrorReport>
- <FileAlignment>512</FileAlignment>
- <WarningLevel>4</WarningLevel>
- <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Ice, Version=3.5.1.0, Culture=neutral, PublicKeyToken=1f998c50fec78381, processorArchitecture=MSIL" />
- <Reference Include="mscorlib" />
- <Reference Include="System" />
- <Reference Include="System.Core" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="System.Data" />
- <Reference Include="System.Drawing" />
- <Reference Include="System.Windows.Forms" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Callback.cs" />
- <Compile Include="CallbackSenderI.cs" />
- <Compile Include="MainForm.cs">
- <SubType>Form</SubType>
- </Compile>
- <Compile Include="MainForm.Designer.cs">
- <DependentUpon>MainForm.cs</DependentUpon>
- </Compile>
- <Compile Include="Program.cs" />
- <EmbeddedResource Include="MainForm.resx">
- <DependentUpon>MainForm.cs</DependentUpon>
- <SubType>Designer</SubType>
- </EmbeddedResource>
- </ItemGroup>
- <ItemGroup>
- <None Include="Callback.ice" />
- </ItemGroup>
- <ItemGroup>
- <Content Include="README.txt" />
- </ItemGroup>
- <ItemGroup>
- <Folder Include="Properties\" />
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.targets" />
- <ProjectExtensions>
- <VisualStudio>
- <FlavorProperties GUID="{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}">
- <HostingProcess disable="1" />
- </FlavorProperties>
- <UserProperties ZerocIce_Enabled="True" />
- </VisualStudio>
- </ProjectExtensions>
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
diff --git a/cs/demo/Ice/compact/bidir/sources b/cs/demo/Ice/compact/bidir/sources
new file mode 100644
index 00000000000..2257e0ae20f
--- /dev/null
+++ b/cs/demo/Ice/compact/bidir/sources
@@ -0,0 +1,49 @@
+RELEASETYPE=MANAGED
+_ISVINCPATH=$(_WINCEROOT)\public\common\sdk\inc;
+_OEMINCPATH=$(_WINCEROOT)\public\common\oak\inc;$(_WINCEROOT)\public\common\sdk\inc;
+
+TARGETTYPE=MANAGED_EXE
+TARGETNAME=bidir
+
+FILE_VIEW_ROOT_FOLDER= \
+ ReadMe.txt \
+ prelink.bat \
+ postlink.bat \
+
+FILE_VIEW_RESOURCE_FOLDER= \
+
+
+FILE_VIEW_INCLUDES_FOLDER= \
+
+SOURCES= \
+ MainForm.cs \
+ MainForm.Designer.cs \
+ Program.cs \
+ CallbackSenderI.cs \
+ Callback.cs \
+
+
+TARGETLIBS= \
+ $(SG_OUTPUT_ROOT)\sdk\lib\$(_CPUINDPATH)\coredll.lib \
+
+
+POSTLINK_PASS_CMD=postlink.bat
+PRELINK_PASS_CMD=prelink.bat
+
+FILE_VIEW_PARAMETER_FOLDER= \
+ bidir.bib \
+ bidir.reg \
+ bidir.dat \
+ bidir.db \
+ ProjSysgen.bat \
+
+MANAGED_REFERENCES=$(_MANAGED_FRAMEWORK_DIR)\mscorlib.dll; \
+ $(_MANAGED_FRAMEWORK_DIR)\system.dll; \
+ $(_MANAGED_FRAMEWORK_DIR)\system.windows.forms.dll; \
+ $(_MANAGED_FRAMEWORK_DIR)\system.drawing.dll; \
+ $(_MANAGED_FRAMEWORK_DIR)\system.data.dll; \
+ ..\..\..\..\Assemblies\cf\Ice.dll \
+
+MANAGED_RESOURCES= \
+
+PBSUBPROJECT=1
diff --git a/cs/demo/Ice/compact/hello/MainForm.cs b/cs/demo/Ice/compact/hello/MainForm.cs
index e7d11102dc0..771df121513 100644
--- a/cs/demo/Ice/compact/hello/MainForm.cs
+++ b/cs/demo/Ice/compact/hello/MainForm.cs
@@ -8,7 +8,6 @@
// **********************************************************************
using System;
-using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@@ -95,7 +94,7 @@ namespace client
},
(Ice.Exception ex) =>
{
- exception(ref haveResponse);
+ exception(ref haveResponse, ex);
}
).whenSent(
(bool sentSynchronously) =>
@@ -116,7 +115,7 @@ namespace client
},
(Ice.Exception ex) =>
{
- exception(ref haveResponse);
+ exception(ref haveResponse, ex);
}
).whenSent(
(bool sentSynchronously) =>
diff --git a/cs/demo/Ice/compact/hello/Prelink.bat b/cs/demo/Ice/compact/hello/Prelink.bat
new file mode 100644
index 00000000000..7b8fc854e72
--- /dev/null
+++ b/cs/demo/Ice/compact/hello/Prelink.bat
@@ -0,0 +1 @@
+@REM Add pre-link commands below.
diff --git a/cs/demo/Ice/compact/hello/Program.cs b/cs/demo/Ice/compact/hello/Program.cs
index 2f1ac867a20..9724cc0cb03 100644
--- a/cs/demo/Ice/compact/hello/Program.cs
+++ b/cs/demo/Ice/compact/hello/Program.cs
@@ -8,8 +8,6 @@
// **********************************************************************
using System;
-using System.Linq;
-using System.Collections.Generic;
using System.Windows.Forms;
namespace client
diff --git a/cs/demo/Ice/compact/hello/ProjSysgen.bat b/cs/demo/Ice/compact/hello/ProjSysgen.bat
new file mode 100644
index 00000000000..543916c9afa
--- /dev/null
+++ b/cs/demo/Ice/compact/hello/ProjSysgen.bat
@@ -0,0 +1,61 @@
+@REM
+@REM Copyright (c) Microsoft Corporation. All rights reserved.
+@REM
+@REM
+@REM Use of this sample source code is subject to the terms of the Microsoft
+@REM license agreement under which you licensed this sample source code. If
+@REM you did not accept the terms of the license agreement, you are not
+@REM authorized to use this sample source code. For the terms of the license,
+@REM please see the license agreement between you and Microsoft or, if applicable,
+@REM see the LICENSE.RTF on your install media or the root of your tools installation.
+@REM THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES OR INDEMNITIES.
+@REM
+if /i not "%1"=="preproc" goto :Not_Preproc
+ goto :EOF
+:Not_Preproc
+if /i not "%1"=="pass1" goto :Not_Pass1
+
+ REM ==============================================================================================
+ REM
+ REM Application Builder Debugging Support
+ REM
+ REM ==============================================================================================
+ if not "%SYSGEN_APPDEBUG%"=="1" goto NoAPPDEBUG
+ set SYSGEN_DCOM=1
+ set SYSGEN_MINGDI=1
+ set SYSGEN_MINGWES=1
+ set SYSGEN_MINWMGR=1
+ set SYSGEN_MSVCP=1
+ set SYSGEN_NETWORKING=1
+ set __SYSGEN_OLEAUT32=1
+ set __SYSGEN_WWSAPI=1
+ set SYSGEN_FSDBASE=1
+ set SYSGEN_MININPUT=1
+ set SYSGEN_TOOLHELP=1
+ :NoAPPDEBUG
+
+ REM ==============================================================================================
+ REM
+ REM Remote Tools Support
+ REM
+ REM ==============================================================================================
+ if not "%SYSGEN_REMOTETOOLS%"=="1" goto NoREMOTETOOLS
+ set SYSGEN_FSDBASE=1
+ set SYSGEN_MINGDI=1
+ set SYSGEN_MINGWES=1
+ set SYSGEN_MININPUT=1
+ set SYSGEN_MINWMGR=1
+ set SYSGEN_NETWORKING=1
+ set SYSGEN_OLE=1
+ set SYSGEN_SHELL=1
+ :NoREMOTETOOLS
+
+ goto :EOF
+:Not_Pass1
+if /i not "%1"=="pass2" goto :Not_Pass2
+ goto :EOF
+:Not_Pass2
+if /i not "%1"=="report" goto :Not_Report
+ goto :EOF
+:Not_Report
+echo %0 Invalid parameter %1
diff --git a/cs/demo/Ice/compact/hello/README.txt b/cs/demo/Ice/compact/hello/README.txt
index 4cd79cecd84..bf410e9450e 100644
--- a/cs/demo/Ice/compact/hello/README.txt
+++ b/cs/demo/Ice/compact/hello/README.txt
@@ -1,63 +1,47 @@
This demo shows how to write a simple C# client application using Ice
-for .NET Compact Framework (CF).
+for .NET Compact Framework (Compact 2013).
This demo requires a hello server. You can use the C# server located
in ..\..\hello, or you can use a server from any other language mapping.
-You must use Visual Studio 2008 to build this client (Visual Studio
-2010 does not support Compact Framework development). Follow these
+You must use Visual Studio 2013 to build this client. Follow these
instructions to build and run the client:
-1) Open the project in Visual Studio 2008. This is a Smart Device
- project and therefore Visual Studio will compile it against the
- Compact Framework libraries. Furthermore, the Ice Visual Studio
- Add-in detects a Smart Device project and automatically
- configures the project to compile against the Ice for .NET CF
- DLL in <Ice installation directory>\Assembles\cf\Ice.dll.
+1) Install Windows Embedded Compact 2013 as described below:
-2) Build the client by right-clicking on the project and choosing
- "Build".
+ http://msdn.microsoft.com/en-us/library/jj200354.aspx
-3) Start a device emulator. Select Tools -> Device Emulator Manager,
- highlight "USA Windows Mobile 5.0 Pocket PC R2 Emulator", and
- select Actions -> Connect.
+2) Setup a Virtual Test Device:
-4) In the emulator window, select File -> Configure, open the Network
- tab, and check "Enable NE2000 PCMCIA network adapter". Open the
- drop-down menu and select the appropriate network adapter, then
- press OK.
+ http://msdn.microsoft.com/en-us/library/jj200348.aspx.
- If you get an error dialog that mentions Virtual PC 2007, you will
- need to install this product to enable network access for the
- emulator. You can download Virtual PC 2007 at the link below:
+3) Create an OS:
- http://www.microsoft.com/downloads/en/details.aspx?FamilyID=04d26402-3199-48a3-afa2-2dc0b40a73b6
+ http://msdn.microsoft.com/en-us/library/jj200351.aspx
- Close the emulator, install Virtual PC 2007, and restart the
- emulator.
+ Ensure that you select "Win32 and WinForms UI Device", and ensure
+ that "Application Debugging support" and "Remote Tools Support" is
+ enabled.
-5) After successfully enabling the network adapter, you may need to
- activate the network connection. Click on the symbol resembling an
- antenna in the device's status bar and choose Connect to start the
- connection. If you wish, start Internet Explorer and verify that
- you can successfully access the Internet.
+4) Build the OS and ensure that it successfully deploys to your
+ virtual device.
-6) In Visual Studio, right-click on the project, choose Deploy, select
- the "USA Windows Mobile 5.0 Pocket PC R2 Emulator" device, and
- click Deploy. This action causes Visual Studio to install the .NET
- CF run time, the client executable, and the Ice for .NET CF run
- time in the emulator.
+5) At this point it may be useful to create a test Subproject to
+ ensure you can build and deploy executables:
-7) In a command window, start the hello server.
+ http://msdn.microsoft.com/en-us/library/jj200344.aspx
-8) In the emulator, choose Start -> Programs and select File Explorer.
- Click on My Documents and choose My Device. Select Program Files,
- then select "client".
+6) Select Subprojects>Add Existing Subproject. Navigate to
+ "cs/demo/Ice/compact/hello" and select "hello.pbpxml".
-9) Finally, select "client" to start the program. In the Hostname
- field, enter the IP address or host name of the machine on which
- the hello server is running. Click the Say Hello button to send a
- request to the server.
+6) Select Build>Build All Subprojects.
+
+7) To run the application, go to Target>Run Programs and select
+ hello.exe.
+
+8) In the client's Hostname field, enter the IP address or host name
+ of the machine on which the hello server is running. Click the
+ Say Hello button to send a request to the server.
Note that the initial request takes a little longer to complete
while the connection is being established.
diff --git a/cs/demo/Ice/compact/hello/Resources/hello.lnk b/cs/demo/Ice/compact/hello/Resources/hello.lnk
new file mode 100755
index 00000000000..a4af63e90a2
--- /dev/null
+++ b/cs/demo/Ice/compact/hello/Resources/hello.lnk
@@ -0,0 +1 @@
+20#\Windows\poonose.exe \ No newline at end of file
diff --git a/cs/demo/Ice/compact/hello/client.csproj b/cs/demo/Ice/compact/hello/client.csproj
deleted file mode 100644
index f628a53b0c8..00000000000
--- a/cs/demo/Ice/compact/hello/client.csproj
+++ /dev/null
@@ -1,99 +0,0 @@
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProductVersion>9.0.21022</ProductVersion>
- <SchemaVersion>2.0</SchemaVersion>
- <ProjectGuid>{95E6B539-E515-4BD4-BDB0-35D7C49C897D}</ProjectGuid>
- <OutputType>WinExe</OutputType>
- <AppDesignerFolder>Properties</AppDesignerFolder>
- <RootNamespace>client</RootNamespace>
- <AssemblyName>client</AssemblyName>
- <ProjectTypeGuids>{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <PlatformFamilyName>PocketPC</PlatformFamilyName>
- <PlatformID>4118C335-430C-497f-BE48-11C3316B135E</PlatformID>
- <OSVersion>5.1</OSVersion>
- <DeployDirSuffix>client</DeployDirSuffix>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <NativePlatformName>Windows Mobile 5.0 Pocket PC SDK</NativePlatformName>
- <FormFactorID>
- </FormFactorID>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>.\</OutputPath>
- <DefineConstants>DEBUG;TRACE;$(PlatformFamilyName)</DefineConstants>
- <NoStdLib>true</NoStdLib>
- <NoConfig>true</NoConfig>
- <ErrorReport>prompt</ErrorReport>
- <FileAlignment>512</FileAlignment>
- <WarningLevel>4</WarningLevel>
- <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugType>pdbonly</DebugType>
- <Optimize>true</Optimize>
- <OutputPath>.\</OutputPath>
- <DefineConstants>TRACE;$(PlatformFamilyName)</DefineConstants>
- <NoStdLib>true</NoStdLib>
- <NoConfig>true</NoConfig>
- <ErrorReport>prompt</ErrorReport>
- <FileAlignment>512</FileAlignment>
- <WarningLevel>4</WarningLevel>
- <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="Ice, Version=3.5.1.0, Culture=neutral, PublicKeyToken=1f998c50fec78381, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- </Reference>
- <Reference Include="mscorlib" />
- <Reference Include="System" />
- <Reference Include="System.Core" />
- <Reference Include="System.Xml.Linq" />
- <Reference Include="System.Data.DataSetExtensions" />
- <Reference Include="System.Data" />
- <Reference Include="System.Drawing" />
- <Reference Include="System.Windows.Forms" />
- <Reference Include="System.Xml" />
- </ItemGroup>
- <ItemGroup>
- <Compile Include="Hello.cs" />
- <Compile Include="MainForm.cs">
- <SubType>Form</SubType>
- </Compile>
- <Compile Include="MainForm.Designer.cs">
- <DependentUpon>MainForm.cs</DependentUpon>
- </Compile>
- <Compile Include="Program.cs" />
- <EmbeddedResource Include="MainForm.resx">
- <DependentUpon>MainForm.cs</DependentUpon>
- </EmbeddedResource>
- </ItemGroup>
- <ItemGroup>
- <None Include="Hello.ice" />
- </ItemGroup>
- <ItemGroup>
- <Content Include="README.txt" />
- </ItemGroup>
- <ItemGroup>
- <Folder Include="Properties\" />
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CompactFramework.CSharp.targets" />
- <ProjectExtensions>
- <VisualStudio>
- <FlavorProperties GUID="{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}">
- <HostingProcess disable="1" />
- </FlavorProperties>
- <UserProperties ZerocIce_Enabled="True" ZerocIce_VerboseLevel="1" />
- </VisualStudio>
- </ProjectExtensions>
- <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
- Other similar extension points exist, see Microsoft.Common.targets.
- <Target Name="BeforeBuild">
- </Target>
- <Target Name="AfterBuild">
- </Target>
- -->
-</Project>
diff --git a/cs/demo/Ice/compact/hello/hello.bib b/cs/demo/Ice/compact/hello/hello.bib
new file mode 100644
index 00000000000..2f85336aea1
--- /dev/null
+++ b/cs/demo/Ice/compact/hello/hello.bib
@@ -0,0 +1,5 @@
+FILES
+; @XIPREGION IF PLATFORM_FILES_MISC
+hello.exe $(_FLATRELEASEDIR)\hello.exe NK U
+Ice.dll $(_FLATRELEASEDIR)\Ice.dll NK U
+; @XIPREGION ENDIF PLATFORM_FILES_MISC
diff --git a/cs/demo/Ice/compact/hello/hello.dat b/cs/demo/Ice/compact/hello/hello.dat
new file mode 100644
index 00000000000..aefd3b08289
--- /dev/null
+++ b/cs/demo/Ice/compact/hello/hello.dat
@@ -0,0 +1,2 @@
+Directory("\Windows"):-Directory("Start Menu")
+Directory("\Windows\Start Menu"):-File("hello.lnk","\Windows\hello.lnk") \ No newline at end of file
diff --git a/cs/demo/Ice/compact/hello/hello.db b/cs/demo/Ice/compact/hello/hello.db
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/cs/demo/Ice/compact/hello/hello.db
diff --git a/cs/demo/Ice/compact/hello/hello.pbpxml b/cs/demo/Ice/compact/hello/hello.pbpxml
new file mode 100644
index 00000000000..0bfffd78e5a
--- /dev/null
+++ b/cs/demo/Ice/compact/hello/hello.pbpxml
@@ -0,0 +1,2 @@
+<?xml version="1.0"?>
+<PBProject BibFile="hello.bib" DatFile="hello.dat" DbFile="hello.db" DisplayName="hello" RegFile="hello.reg" xmlns="urn:PBProject-schema" /> \ No newline at end of file
diff --git a/cs/demo/Ice/compact/hello/hello.reg b/cs/demo/Ice/compact/hello/hello.reg
new file mode 100644
index 00000000000..011f0f4c942
--- /dev/null
+++ b/cs/demo/Ice/compact/hello/hello.reg
@@ -0,0 +1,8 @@
+
+;MinShell Menu Registry Entries;==============================
+
+; Run Menu for hello
+[HKEY_LOCAL_MACHINE\Software\Compact13Tools\Shell\Minshell\hello]
+ "App"="hello.exe"
+ "Param"=""
+
diff --git a/cs/demo/Ice/compact/hello/postlink.bat b/cs/demo/Ice/compact/hello/postlink.bat
new file mode 100644
index 00000000000..9edb6af52fc
--- /dev/null
+++ b/cs/demo/Ice/compact/hello/postlink.bat
@@ -0,0 +1,34 @@
+
+@echo copying Content Files from Resource Files folder to Targeted Debug Directory
+copy ".\Resources\*.*" "%SG_OUTPUT_ROOT%\oak\target\%_TGTCPU%\%WINCEDEBUG%" /Y
+
+@echo copying Content Files from Resource Files folder to FlatRelease Directory
+copy ".\Resources\*.*" %_FLATRELEASEDIR% /Y
+@echo copying DLLs FlatRelease Directory
+copy "..\..\..\..\Assemblies\cf\Ice.dll" %_FLATRELEASEDIR% /Y
+
+@echo .
+@echo Building .cab file
+@echo .
+
+PUSHD
+cd %_FLATRELEASEDIR%
+IF EXIST hello.inf (
+ cabwiz hello.inf
+ IF EXIST hello.cab (
+ @echo Generated .cab file: hello.cab in FLATRELEASEDIR.
+ ) else (
+ @echo Generation of .cab file: hello.cab failed.
+ )
+)else (
+ @echo No file hello.inf for .cab file generation
+)
+
+POPD
+
+@echo .
+@echo Done Copying
+@echo .
+
+:SKIP
+
diff --git a/cs/demo/Ice/compact/hello/sources b/cs/demo/Ice/compact/hello/sources
new file mode 100644
index 00000000000..35aa499685b
--- /dev/null
+++ b/cs/demo/Ice/compact/hello/sources
@@ -0,0 +1,48 @@
+RELEASETYPE=MANAGED
+_ISVINCPATH=$(_WINCEROOT)\public\common\sdk\inc;
+_OEMINCPATH=$(_WINCEROOT)\public\common\oak\inc;$(_WINCEROOT)\public\common\sdk\inc;
+
+TARGETTYPE=MANAGED_EXE
+TARGETNAME=hello
+
+FILE_VIEW_ROOT_FOLDER= \
+ ReadMe.txt \
+ prelink.bat \
+ postlink.bat \
+
+FILE_VIEW_RESOURCE_FOLDER= \
+
+
+FILE_VIEW_INCLUDES_FOLDER= \
+
+SOURCES= \
+ MainForm.cs \
+ MainForm.Designer.cs \
+ Program.cs \
+ Hello.cs \
+
+
+TARGETLIBS= \
+ $(SG_OUTPUT_ROOT)\sdk\lib\$(_CPUINDPATH)\coredll.lib \
+
+
+POSTLINK_PASS_CMD=postlink.bat
+PRELINK_PASS_CMD=prelink.bat
+
+FILE_VIEW_PARAMETER_FOLDER= \
+ hello.bib \
+ hello.reg \
+ hello.dat \
+ hello.db \
+ ProjSysgen.bat \
+
+MANAGED_REFERENCES=$(_MANAGED_FRAMEWORK_DIR)\mscorlib.dll; \
+ $(_MANAGED_FRAMEWORK_DIR)\system.dll; \
+ $(_MANAGED_FRAMEWORK_DIR)\system.windows.forms.dll; \
+ $(_MANAGED_FRAMEWORK_DIR)\system.drawing.dll; \
+ $(_MANAGED_FRAMEWORK_DIR)\system.data.dll; \
+ ..\..\..\..\Assemblies\cf\Ice.dll \
+
+MANAGED_RESOURCES= \
+
+PBSUBPROJECT=1
diff --git a/cs/demo/Ice/multicast/DiscoverReplyI.cs b/cs/demo/Ice/multicast/DiscoverReplyI.cs
index b28d69de29f..1119a832856 100644
--- a/cs/demo/Ice/multicast/DiscoverReplyI.cs
+++ b/cs/demo/Ice/multicast/DiscoverReplyI.cs
@@ -15,21 +15,6 @@ public class DiscoverReplyI : DiscoverReplyDisp_
public override void
reply(Ice.ObjectPrx obj, Ice.Current current)
{
-#if COMPACT
- _m.Lock();
- try
- {
- if(_obj == null)
- {
- _obj = obj;
- }
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
- }
-#else
lock(this)
{
if(_obj == null)
@@ -38,36 +23,11 @@ public class DiscoverReplyI : DiscoverReplyDisp_
}
Monitor.Pulse(this);
}
-#endif
}
public Ice.ObjectPrx
waitReply(long timeout)
{
-#if COMPACT
- _m.Lock();
- try
- {
- long end = System.DateTime.Now.Ticks / 1000 + timeout;
- while(_obj == null)
- {
- int delay = (int)(end - System.DateTime.Now.Ticks / 1000);
- if(delay > 0)
- {
- _m.TimedWait(delay);
- }
- else
- {
- break;
- }
- }
- return _obj;
- }
- finally
- {
- _m.Unlock();
- }
-#else
lock(this)
{
long end = System.DateTime.Now.Ticks / 1000 + timeout;
@@ -85,11 +45,7 @@ public class DiscoverReplyI : DiscoverReplyDisp_
}
return _obj;
}
-#endif
}
private Ice.ObjectPrx _obj;
-#if COMPACT
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
-#endif
}
diff --git a/cs/demo/Ice/properties/Server.cs b/cs/demo/Ice/properties/Server.cs
index fff449dbbf5..70d9e19604b 100644
--- a/cs/demo/Ice/properties/Server.cs
+++ b/cs/demo/Ice/properties/Server.cs
@@ -23,12 +23,11 @@ public class Server : Ice.Application
public PropsI()
{
_called = false;
- _monitor = new IceUtilInternal.Monitor();
}
override public Dictionary<string, string> getChanges(Ice.Current current)
{
- lock(_monitor)
+ lock(this)
{
//
// Make sure that we have received the property updates before we
@@ -36,7 +35,7 @@ public class Server : Ice.Application
//
while(!_called)
{
- _monitor.Wait();
+ System.Threading.Monitor.Wait(this);
}
_called = false;
@@ -51,17 +50,16 @@ public class Server : Ice.Application
public void updated(Dictionary<string, string> changes)
{
- lock(_monitor)
+ lock(this)
{
_changes = changes;
_called = true;
- _monitor.Notify();
+ System.Threading.Monitor.Pulse(this);
}
}
Dictionary<string, string> _changes;
private bool _called;
- IceUtilInternal.Monitor _monitor;
}
override public int run(string[] args)
diff --git a/cs/demo/Ice/session/Client.cs b/cs/demo/Ice/session/Client.cs
index a08f4dd3060..e83ba26234b 100644
--- a/cs/demo/Ice/session/Client.cs
+++ b/cs/demo/Ice/session/Client.cs
@@ -35,32 +35,6 @@ public class Client
public void run()
{
-#if COMPACT
- _m.Lock();
- try
- {
- while(!_terminated)
- {
- _m.TimedWait(_timeout);
- if(!_terminated)
- {
- try
- {
- _session.refresh();
- }
- catch(Ice.Exception ex)
- {
- _logger.warning("SessionRefreshThread: " + ex);
- _terminated = true;
- }
- }
- }
- }
- finally
- {
- _m.Unlock();
- }
-#else
lock(this)
{
while(!_terminated)
@@ -80,38 +54,21 @@ public class Client
}
}
}
-#endif
}
public void terminate()
{
-#if COMPACT
- _m.Lock();
- try
- {
- _terminated = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
- }
-#else
lock(this)
{
_terminated = true;
Monitor.Pulse(this);
}
-#endif
}
private Ice.Logger _logger;
private SessionPrx _session;
private int _timeout;
private bool _terminated;
-#if COMPACT
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
-#endif
}
public override int run(string[] args)
diff --git a/cs/demo/Ice/session/ReapThread.cs b/cs/demo/Ice/session/ReapThread.cs
index f90e96cdcaf..8527b715451 100644
--- a/cs/demo/Ice/session/ReapThread.cs
+++ b/cs/demo/Ice/session/ReapThread.cs
@@ -35,50 +35,6 @@ public class ReapThread
public void run()
{
-#if COMPACT
- _m.Lock();
- try
- {
- while(!_terminated)
- {
- _m.TimedWait(1000);
- if(!_terminated)
- {
- ArrayList tmp = new ArrayList();
- foreach(SessionProxyPair p in _sessions)
- {
- try
- {
- //
- // Session destruction may take time in a
- // real-world example. Therefore the current time
- // is computed for each iteration.
- //
- if((System.DateTime.Now - p.session.timestamp()) > _timeout)
- {
- string name = p.proxy.getName();
- p.proxy.destroy();
- Console.Out.WriteLine("The session " + name + " has timed out.");
- }
- else
- {
- tmp.Add(p);
- }
- }
- catch(Ice.ObjectNotExistException)
- {
- // Ignore.
- }
- }
- _sessions = tmp;
- }
- }
- }
- finally
- {
- _m.Unlock();
- }
-#else
lock(this)
{
while(!_terminated)
@@ -116,25 +72,10 @@ public class ReapThread
}
}
}
-#endif
}
public void terminate()
{
-#if COMPACT
- _m.Lock();
- try
- {
- _terminated = true;
- _m.Notify();
-
- _sessions.Clear();
- }
- finally
- {
- _m.Unlock();
- }
-#else
lock(this)
{
_terminated = true;
@@ -142,33 +83,17 @@ public class ReapThread
_sessions.Clear();
}
-#endif
}
public void add(SessionPrx proxy, SessionI session)
{
-#if COMPACT
- _m.Lock();
- try
- {
- _sessions.Add(new SessionProxyPair(proxy, session));
- }
- finally
- {
- _m.Unlock();
- }
-#else
lock(this)
{
_sessions.Add(new SessionProxyPair(proxy, session));
}
-#endif
}
private bool _terminated;
private System.TimeSpan _timeout;
private ArrayList _sessions;
-#if COMPACT
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
-#endif
}
diff --git a/cs/demo/democf.sln b/cs/demo/democf.sln
deleted file mode 100755
index 9ac35691ab1..00000000000
--- a/cs/demo/democf.sln
+++ /dev/null
@@ -1,38 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 10.00
-# Visual Studio 2008
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "client", "Ice\compact\hello\client.csproj", "{95E6B539-E515-4BD4-BDB0-35D7C49C897D}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "hello", "hello", "{853FE674-7861-4714-A941-FF365EF4DF2A}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "bidir", "bidir", "{2E7BE181-7EE0-4A89-92F8-724F9FDC3DDD}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "server", "Ice\compact\bidir\server.csproj", "{05B11482-32A1-4212-A7F8-2A135FADD164}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {95E6B539-E515-4BD4-BDB0-35D7C49C897D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {95E6B539-E515-4BD4-BDB0-35D7C49C897D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {95E6B539-E515-4BD4-BDB0-35D7C49C897D}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
- {95E6B539-E515-4BD4-BDB0-35D7C49C897D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {95E6B539-E515-4BD4-BDB0-35D7C49C897D}.Release|Any CPU.Build.0 = Release|Any CPU
- {95E6B539-E515-4BD4-BDB0-35D7C49C897D}.Release|Any CPU.Deploy.0 = Release|Any CPU
- {05B11482-32A1-4212-A7F8-2A135FADD164}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {05B11482-32A1-4212-A7F8-2A135FADD164}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {05B11482-32A1-4212-A7F8-2A135FADD164}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
- {05B11482-32A1-4212-A7F8-2A135FADD164}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {05B11482-32A1-4212-A7F8-2A135FADD164}.Release|Any CPU.Build.0 = Release|Any CPU
- {05B11482-32A1-4212-A7F8-2A135FADD164}.Release|Any CPU.Deploy.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(NestedProjects) = preSolution
- {95E6B539-E515-4BD4-BDB0-35D7C49C897D} = {853FE674-7861-4714-A941-FF365EF4DF2A}
- {05B11482-32A1-4212-A7F8-2A135FADD164} = {2E7BE181-7EE0-4A89-92F8-724F9FDC3DDD}
- EndGlobalSection
-EndGlobal
diff --git a/cs/src/Glacier2/Application.cs b/cs/src/Glacier2/Application.cs
index d5ff6b9ad3d..50790b7e4f1 100644
--- a/cs/src/Glacier2/Application.cs
+++ b/cs/src/Glacier2/Application.cs
@@ -193,8 +193,7 @@ public abstract class Application : Ice.Application
throw new SessionNotExistException();
}
- mutex__.Lock();
- try
+ lock(mutex__)
{
if(_adapter == null)
{
@@ -202,10 +201,6 @@ public abstract class Application : Ice.Application
_adapter.activate();
}
}
- finally
- {
- mutex__.Unlock();
- }
return _adapter;
}
@@ -222,8 +217,7 @@ public abstract class Application : Ice.Application
public void
run()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_done)
{
@@ -246,39 +240,29 @@ public abstract class Application : Ice.Application
if(!_done)
{
- _m.TimedWait((int)_period);
+ System.Threading.Monitor.Wait(this, (int)_period);
}
}
}
- finally
- {
- _m.Unlock();
- }
}
public void
done()
{
- _m.Lock();
- try
+ lock(this)
{
if(!_done)
{
_done = true;
- _m.NotifyAll();
+ System.Threading.Monitor.PulseAll(this);
}
}
- finally
- {
- _m.Unlock();
- }
}
private Application _app;
private Glacier2.RouterPrx _router;
private long _period;
private bool _done = false;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
private class ConnectionCallbackI : Ice.ConnectionCallback
@@ -466,12 +450,11 @@ public abstract class Application : Ice.Application
ignoreInterrupt();
}
- mutex__.Lock();
- try
+ lock(mutex__)
{
while(callbackInProgress__)
{
- mutex__.Wait();
+ System.Threading.Monitor.Wait(mutex__);
}
if(destroyed__)
@@ -488,10 +471,6 @@ public abstract class Application : Ice.Application
//
}
}
- finally
- {
- mutex__.Unlock();
- }
if(ping != null)
{
diff --git a/cs/src/Glacier2/SessionHelper.cs b/cs/src/Glacier2/SessionHelper.cs
index 3c59333f21b..21db83ffe9d 100644
--- a/cs/src/Glacier2/SessionHelper.cs
+++ b/cs/src/Glacier2/SessionHelper.cs
@@ -33,8 +33,7 @@ public class SessionHelper
public void
run()
{
- _m.Lock();
- try
+ lock(this)
{
while(true)
{
@@ -58,11 +57,11 @@ public class SessionHelper
if(!_done)
{
#if COMPACT || SILVERLIGHT
- _m.TimedWait(_period);
+ System.Threading.Monitor.Wait(this, _period);
#else
try
{
- _m.TimedWait(_period);
+ System.Threading.Monitor.Wait(this, _period);
}
catch(ThreadInterruptedException)
{
@@ -76,36 +75,25 @@ public class SessionHelper
}
}
}
- finally
- {
- _m.Unlock();
- }
}
public void
done()
{
- _m.Lock();
- try
+ lock(this)
{
if(!_done)
{
_done = true;
- _m.Notify();
+ System.Threading.Monitor.Pulse(this);
}
}
- finally
- {
- _m.Unlock();
- }
}
private SessionHelper _session;
private Glacier2.RouterPrx _router;
private int _period;
private bool _done = false;
-
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
private class ConnectionCallbackI : Ice.ConnectionCallback
diff --git a/cs/src/Ice/Application.cs b/cs/src/Ice/Application.cs
index e1feea5f739..cea472c0e46 100644
--- a/cs/src/Ice/Application.cs
+++ b/cs/src/Ice/Application.cs
@@ -285,20 +285,15 @@ namespace Ice
{
if(signalPolicy__ == SignalPolicy.HandleSignals)
{
- mutex__.Lock();
- try
+ lock(mutex__)
{
if(_callback == _holdCallback)
{
released__ = true;
- mutex__.Notify();
+ System.Threading.Monitor.Pulse(mutex__);
}
_callback = _destroyCallback;
}
- finally
- {
- mutex__.Unlock();
- }
}
else
{
@@ -314,20 +309,15 @@ namespace Ice
{
if(signalPolicy__ == SignalPolicy.HandleSignals)
{
- mutex__.Lock();
- try
+ lock(mutex__)
{
if(_callback == _holdCallback)
{
released__ = true;
- mutex__.Notify();
+ System.Threading.Monitor.Pulse(mutex__);
}
_callback = _shutdownCallback;
}
- finally
- {
- mutex__.Unlock();
- }
}
else
{
@@ -343,20 +333,15 @@ namespace Ice
{
if(signalPolicy__ == SignalPolicy.HandleSignals)
{
- mutex__.Lock();
- try
+ lock(mutex__)
{
if(_callback == _holdCallback)
{
released__ = true;
- mutex__.Notify();
+ System.Threading.Monitor.Pulse(mutex__);
}
_callback = null;
}
- finally
- {
- mutex__.Unlock();
- }
}
else
{
@@ -373,20 +358,15 @@ namespace Ice
{
if(signalPolicy__ == SignalPolicy.HandleSignals)
{
- mutex__.Lock();
- try
+ lock(mutex__)
{
if(_callback == _holdCallback)
{
released__ = true;
- mutex__.Notify();
+ System.Threading.Monitor.Pulse(mutex__);
}
_callback = _userCallback;
}
- finally
- {
- mutex__.Unlock();
- }
}
else
{
@@ -402,8 +382,7 @@ namespace Ice
{
if(signalPolicy__ == SignalPolicy.HandleSignals)
{
- mutex__.Lock();
- try
+ lock(mutex__)
{
if(_callback != _holdCallback)
{
@@ -413,10 +392,6 @@ namespace Ice
}
// else, we were already holding signals
}
- finally
- {
- mutex__.Unlock();
- }
}
else
{
@@ -433,28 +408,23 @@ namespace Ice
{
if(signalPolicy__ == SignalPolicy.HandleSignals)
{
- mutex__.Lock();
- try
+ lock(mutex__)
{
if(_callback == _holdCallback)
{
//
// Note that it's very possible no signal is held;
// in this case the callback is just replaced and
- // setting released__ to true and signalling mutex__
- // do no harm.
+ // setting released__ to true and signalling this
+ // will do no harm.
//
released__ = true;
_callback = _previousCallback;
- mutex__.Notify();
+ System.Threading.Monitor.Pulse(mutex__);
}
// Else nothing to release.
}
- finally
- {
- mutex__.Unlock();
- }
}
else
{
@@ -470,15 +440,10 @@ namespace Ice
/// <returns>True if a signal caused the communicator to shut down; false otherwise.</returns>
public static bool interrupted()
{
- mutex__.Lock();
- try
+ lock(mutex__)
{
return interrupted__;
}
- finally
- {
- mutex__.Unlock();
- }
}
protected virtual int doMain(string[] args, InitializationData initData)
@@ -531,12 +496,11 @@ namespace Ice
ignoreInterrupt();
}
- mutex__.Lock();
- try
+ lock(this)
{
while(callbackInProgress__)
{
- mutex__.Wait();
+ System.Threading.Monitor.Wait(this);
}
if(destroyed__)
{
@@ -553,10 +517,6 @@ namespace Ice
}
_application = null;
}
- finally
- {
- mutex__.Unlock();
- }
if(communicator__ != null)
{
@@ -587,15 +547,10 @@ namespace Ice
{
Callback callback;
- mutex__.Lock();
- try
+ lock(mutex__)
{
callback = _callback;
}
- finally
- {
- mutex__.Unlock();
- }
if(callback != null)
{
@@ -616,12 +571,11 @@ namespace Ice
private static void holdInterruptCallback(int sig)
{
Callback callback = null;
- mutex__.Lock();
- try
+ lock(mutex__)
{
while(!released__)
{
- mutex__.Wait();
+ System.Threading.Monitor.Wait(mutex__);
}
if(destroyed__)
@@ -634,10 +588,6 @@ namespace Ice
callback = _callback;
}
- finally
- {
- mutex__.Unlock();
- }
if(callback != null)
{
@@ -650,8 +600,7 @@ namespace Ice
//
private static void destroyOnInterruptCallback(int sig)
{
- mutex__.Lock();
- try
+ lock(mutex__)
{
if(destroyed__)
{
@@ -670,10 +619,6 @@ namespace Ice
interrupted__ = true;
destroyed__ = true;
}
- finally
- {
- mutex__.Unlock();
- }
try
{
@@ -685,22 +630,16 @@ namespace Ice
Util.getProcessLogger().error("(while destroying in response to signal " + sig + "):\n" + ex);
}
- mutex__.Lock();
- try
+ lock(mutex__)
{
callbackInProgress__ = false;
- mutex__.Notify();
- }
- finally
- {
- mutex__.Unlock();
+ System.Threading.Monitor.Pulse(mutex__);
}
}
private static void shutdownOnInterruptCallback(int sig)
{
- mutex__.Lock();
- try
+ lock(mutex__)
{
if(destroyed__)
{
@@ -718,10 +657,6 @@ namespace Ice
callbackInProgress__ = true;
interrupted__ = true;
}
- finally
- {
- mutex__.Unlock();
- }
try
{
@@ -733,22 +668,16 @@ namespace Ice
Util.getProcessLogger().error("(while shutting down in response to signal " + sig + "):\n" + ex);
}
- mutex__.Lock();
- try
+ lock(mutex__)
{
callbackInProgress__ = false;
- mutex__.Notify();
- }
- finally
- {
- mutex__.Unlock();
+ System.Threading.Monitor.Pulse(mutex__);
}
}
private static void userCallbackOnInterruptCallback(int sig)
{
- mutex__.Lock();
- try
+ lock(mutex__)
{
if(destroyed__)
{
@@ -763,10 +692,6 @@ namespace Ice
callbackInProgress__ = true;
interrupted__ = true;
}
- finally
- {
- mutex__.Unlock();
- }
try
{
@@ -778,20 +703,14 @@ namespace Ice
Util.getProcessLogger().error("(while interrupting in response to signal " + sig + "):\n" + ex);
}
- mutex__.Lock();
- try
+ lock(mutex__)
{
callbackInProgress__ = false;
- mutex__.Notify();
- }
- finally
- {
- mutex__.Unlock();
+ System.Threading.Monitor.Pulse(mutex__);
}
}
- protected static readonly IceUtilInternal.Monitor mutex__ = new IceUtilInternal.Monitor();
-
+ protected static object mutex__ = new object();
protected static bool callbackInProgress__ = false;
protected static bool destroyed__ = false;
protected static bool interrupted__ = false;
@@ -903,15 +822,10 @@ namespace Ice
public void destroy()
{
- _m.Lock();
- try
+ lock(this)
{
_destroyed = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
if(_thread != null)
@@ -923,15 +837,10 @@ namespace Ice
private void callback(int sig)
{
- _m.Lock();
- try
+ lock(this)
{
_signals.Add(sig);
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
@@ -942,12 +851,11 @@ namespace Ice
List<int> signals = null;
bool destroyed = false;
- _m.Lock();
- try
+ lock(this)
{
if(!_destroyed && _signals.Count == 0)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
if(_signals.Count > 0)
@@ -958,10 +866,6 @@ namespace Ice
destroyed = _destroyed;
}
- finally
- {
- _m.Unlock();
- }
if(signals != null)
{
@@ -980,7 +884,6 @@ namespace Ice
private SignalHandler _handler;
private bool _destroyed;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
private Thread _thread;
private List<int> _signals = new List<int>();
}
diff --git a/cs/src/Ice/AsyncIOThread.cs b/cs/src/Ice/AsyncIOThread.cs
index 2a8fce23ff0..91d15a94201 100644
--- a/cs/src/Ice/AsyncIOThread.cs
+++ b/cs/src/Ice/AsyncIOThread.cs
@@ -42,8 +42,7 @@ namespace IceInternal
public void
updateObserver()
{
- _m.Lock();
- try
+ lock(this)
{
Ice.Instrumentation.CommunicatorObserver obsv = _instance.getObserver();
if(obsv != null)
@@ -57,40 +56,26 @@ namespace IceInternal
_observer.attach();
}
}
- }
- finally
- {
- _m.Unlock();
}
}
public void queue(ThreadPoolWorkItem callback)
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_destroyed);
_queue.AddLast(callback);
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
public void destroy()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_destroyed);
_destroyed = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
@@ -108,8 +93,7 @@ namespace IceInternal
bool inUse = false;
while(true)
{
- _m.Lock();
- try
+ lock(this)
{
if(_observer != null && inUse)
{
@@ -125,7 +109,7 @@ namespace IceInternal
while(!_destroyed && _queue.Count == 0)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
LinkedList<ThreadPoolWorkItem> tmp = queue;
@@ -139,10 +123,6 @@ namespace IceInternal
inUse = true;
}
}
- finally
- {
- _m.Unlock();
- }
foreach(ThreadPoolWorkItem cb in queue)
{
@@ -224,6 +204,5 @@ namespace IceInternal
}
private HelperThread _thread;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
}
diff --git a/cs/src/Ice/ConnectRequestHandler.cs b/cs/src/Ice/ConnectRequestHandler.cs
index 340da2b4f7f..2c1b4123781 100644
--- a/cs/src/Ice/ConnectRequestHandler.cs
+++ b/cs/src/Ice/ConnectRequestHandler.cs
@@ -46,8 +46,7 @@ namespace IceInternal
{
_reference.getConnection(this);
- _m.Lock();
- try
+ lock(this)
{
if(initialized())
{
@@ -61,20 +60,15 @@ namespace IceInternal
return this;
}
}
- finally
- {
- _m.Unlock();
- }
}
public void prepareBatchRequest(BasicStream os)
{
- _m.Lock();
- try
+ lock(this)
{
while(_batchRequestInProgress)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
try
@@ -91,23 +85,18 @@ namespace IceInternal
throw new RetryException(ex);
}
}
- finally
- {
- _m.Unlock();
- }
_connection.prepareBatchRequest(os);
}
public void finishBatchRequest(BasicStream os)
{
- _m.Lock();
- try
+ lock(this)
{
if(!initialized()) // This can't throw until _batchRequestInProgress = false
{
Debug.Assert(_batchRequestInProgress);
_batchRequestInProgress = false;
- _m.NotifyAll();
+ System.Threading.Monitor.PulseAll(this);
_batchStream.swap(os);
@@ -121,23 +110,18 @@ namespace IceInternal
return;
}
}
- finally
- {
- _m.Unlock();
- }
_connection.finishBatchRequest(os, _compress);
}
public void abortBatchRequest()
{
- _m.Lock();
- try
+ lock(this)
{
if(!initialized()) // This can't throw until _batchRequestInProgress = false
{
Debug.Assert(_batchRequestInProgress);
_batchRequestInProgress = false;
- _m.NotifyAll();
+ System.Threading.Monitor.PulseAll(this);
BasicStream dummy = new BasicStream(_reference.getInstance(), Ice.Util.currentProtocolEncoding,
_batchAutoFlush);
@@ -147,17 +131,12 @@ namespace IceInternal
return;
}
}
- finally
- {
- _m.Unlock();
- }
_connection.abortBatchRequest();
}
public bool sendRequest(OutgoingMessageCallback @out)
{
- _m.Lock();
- try
+ lock(this)
{
try
{
@@ -172,10 +151,6 @@ namespace IceInternal
throw new RetryException(ex);
}
}
- finally
- {
- _m.Unlock();
- }
// Finished if sent and no response.
return @out.send(_connection, _compress, _response) && !_response;
@@ -183,8 +158,7 @@ namespace IceInternal
public bool sendAsyncRequest(OutgoingAsyncMessageCallback outAsync, out Ice.AsyncCallback sentCallback)
{
- _m.Lock();
- try
+ lock(this)
{
try
{
@@ -200,17 +174,12 @@ namespace IceInternal
throw new RetryException(ex);
}
}
- finally
- {
- _m.Unlock();
- }
return outAsync.send__(_connection, _compress, _response, out sentCallback);
}
public void requestTimedOut(OutgoingMessageCallback @out)
{
- _m.Lock();
- try
+ lock(this)
{
if(_exception != null)
{
@@ -234,17 +203,12 @@ namespace IceInternal
Debug.Assert(false); // The request has to be queued if it timed out and we're not initialized yet.
}
}
- finally
- {
- _m.Unlock();
- }
_connection.requestTimedOut(@out);
}
public void asyncRequestTimedOut(OutgoingAsyncMessageCallback outAsync)
{
- _m.Lock();
- try
+ lock(this)
{
if(_exception != null)
{
@@ -268,10 +232,6 @@ namespace IceInternal
Debug.Assert(false); // The request has to be queued if it timed out and we're not initialized yet.
}
}
- finally
- {
- _m.Unlock();
- }
_connection.asyncRequestTimedOut(outAsync);
}
@@ -284,21 +244,16 @@ namespace IceInternal
{
if(waitInit)
{
- _m.Lock();
- try
+ lock(this)
{
//
// Wait for the connection establishment to complete or fail.
//
while(!_initialized && _exception == null)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
}
- finally
- {
- _m.Unlock();
- }
}
if(_exception != null)
@@ -318,8 +273,7 @@ namespace IceInternal
public void setConnection(Ice.ConnectionI connection, bool compress)
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(_exception == null && _connection == null);
Debug.Assert(_updateRequestHandler || _requests.Count == 0);
@@ -327,10 +281,6 @@ namespace IceInternal
_connection = connection;
_compress = compress;
}
- finally
- {
- _m.Unlock();
- }
//
// If this proxy is for a non-local object, and we are using a router, then
@@ -350,8 +300,7 @@ namespace IceInternal
public void setException(Ice.LocalException ex)
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_initialized && _exception == null);
Debug.Assert(_updateRequestHandler || _requests.Count == 0);
@@ -373,11 +322,7 @@ namespace IceInternal
}, _connection);
}
- _m.NotifyAll();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.PulseAll(this);
}
}
@@ -419,7 +364,7 @@ namespace IceInternal
{
while(_flushing && _exception == null)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
if(_exception != null)
@@ -435,14 +380,13 @@ namespace IceInternal
private void flushRequests()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(_connection != null && !_initialized);
while(_batchRequestInProgress)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
//
@@ -452,10 +396,6 @@ namespace IceInternal
//
_flushing = true;
}
- finally
- {
- _m.Unlock();
- }
LinkedList<Request> sentCallbacks = new LinkedList<Request>();
try
@@ -508,8 +448,7 @@ namespace IceInternal
// was an exception that occured while sending the
// request.
//
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(_exception == null && _requests.Count > 0);
_exception = ex.get();
@@ -519,15 +458,10 @@ namespace IceInternal
flushRequestsWithException();
}, _connection);
}
- finally
- {
- _m.Unlock();
- }
}
catch(Ice.LocalException ex)
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(_exception == null && _requests.Count > 0);
_exception = ex;
@@ -537,10 +471,6 @@ namespace IceInternal
flushRequestsWithException();
}, _connection);
}
- finally
- {
- _m.Unlock();
- }
}
if(sentCallbacks.Count > 0)
@@ -573,8 +503,7 @@ namespace IceInternal
_proxy.setRequestHandler__(this, new ConnectionRequestHandler(_reference, _connection, _compress));
}
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_initialized);
if(_exception == null)
@@ -583,11 +512,7 @@ namespace IceInternal
_flushing = false;
}
_proxy = null; // Break cyclic reference count.
- _m.NotifyAll();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.PulseAll(this);
}
}
@@ -626,7 +551,5 @@ namespace IceInternal
private int _batchRequestsSize;
private BasicStream _batchStream;
private bool _updateRequestHandler;
-
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
}
diff --git a/cs/src/Ice/ConnectionFactory.cs b/cs/src/Ice/ConnectionFactory.cs
index 007d32ceac9..2c39394ffd9 100644
--- a/cs/src/Ice/ConnectionFactory.cs
+++ b/cs/src/Ice/ConnectionFactory.cs
@@ -55,8 +55,7 @@ namespace IceInternal
public void destroy()
{
- _m.Lock();
- try
+ lock(this)
{
if(_destroyed)
{
@@ -73,18 +72,13 @@ namespace IceInternal
_destroyed = true;
_communicator = null;
- _m.NotifyAll();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.PulseAll(this);
}
}
public void updateConnectionObservers()
{
- _m.Lock();
- try
+ lock(this)
{
foreach(ICollection<Ice.ConnectionI> connections in _connections.Values)
{
@@ -94,17 +88,12 @@ namespace IceInternal
}
}
}
- finally
- {
- _m.Unlock();
- }
}
public void waitUntilFinished()
{
Dictionary<Connector, ICollection<Ice.ConnectionI>> connections = null;
- _m.Lock();
- try
+ lock(this)
{
//
// First we wait until the factory is destroyed. We also
@@ -114,7 +103,7 @@ namespace IceInternal
//
while(!_destroyed || _pending.Count > 0 || _pendingConnectCount > 0)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
//
@@ -123,10 +112,6 @@ namespace IceInternal
//
connections = new Dictionary<Connector, ICollection<Ice.ConnectionI>>(_connections);
}
- finally
- {
- _m.Unlock();
- }
//
// Now we wait until the destruction of each connection is finished.
@@ -139,8 +124,7 @@ namespace IceInternal
}
}
- _m.Lock();
- try
+ lock(this)
{
// Ensure all the connections are finished and reapable at this point.
ICollection<Ice.ConnectionI> cons = _monitor.swapReapedConnections();
@@ -162,10 +146,6 @@ namespace IceInternal
}
_monitor.destroy();
}
- finally
- {
- _m.Unlock();
- }
}
public Ice.ConnectionI create(EndpointI[] endpts, bool hasMore, Ice.EndpointSelectionType selType,
@@ -358,8 +338,7 @@ namespace IceInternal
public void setRouterInfo(IceInternal.RouterInfo routerInfo)
{
- _m.Lock();
- try
+ lock(this)
{
if(_destroyed)
{
@@ -412,16 +391,11 @@ namespace IceInternal
}
}
}
- finally
- {
- _m.Unlock();
- }
}
public void removeAdapter(Ice.ObjectAdapter adapter)
{
- _m.Lock();
- try
+ lock(this)
{
if(_destroyed)
{
@@ -439,18 +413,13 @@ namespace IceInternal
}
}
}
- finally
- {
- _m.Unlock();
- }
}
public void flushAsyncBatchRequests(CommunicatorBatchOutgoingAsync outAsync)
{
ICollection<Ice.ConnectionI> c = new List<Ice.ConnectionI>();
- _m.Lock();
- try
+ lock(this)
{
if(!_destroyed)
{
@@ -466,10 +435,6 @@ namespace IceInternal
}
}
}
- finally
- {
- _m.Unlock();
- }
foreach(Ice.ConnectionI conn in c)
{
@@ -520,8 +485,7 @@ namespace IceInternal
private Ice.ConnectionI findConnection(List<EndpointI> endpoints, out bool compress)
{
- _m.Lock();
- try
+ lock(this)
{
if(_destroyed)
{
@@ -559,10 +523,6 @@ namespace IceInternal
compress = false; // Satisfy the compiler
return null;
}
- finally
- {
- _m.Unlock();
- }
}
//
@@ -615,8 +575,7 @@ namespace IceInternal
// the asynchronous requests waiting on a connection to be established.
//
- _m.Lock();
- try
+ lock(this)
{
if(_destroyed)
{
@@ -624,34 +583,24 @@ namespace IceInternal
}
++_pendingConnectCount;
}
- finally
- {
- _m.Unlock();
- }
}
internal void decPendingConnectCount()
{
- _m.Lock();
- try
+ lock(this)
{
--_pendingConnectCount;
Debug.Assert(_pendingConnectCount >= 0);
if(_destroyed && _pendingConnectCount == 0)
{
- _m.NotifyAll();
+ System.Threading.Monitor.PulseAll(this);
}
}
- finally
- {
- _m.Unlock();
- }
}
private Ice.ConnectionI getConnection(List<ConnectorInfo> connectors, ConnectCallback cb, out bool compress)
{
- _m.Lock();
- try
+ lock(this)
{
if(_destroyed)
{
@@ -703,7 +652,7 @@ namespace IceInternal
//
if(cb == null)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
else
{
@@ -721,10 +670,6 @@ namespace IceInternal
}
}
}
- finally
- {
- _m.Unlock();
- }
//
// At this point, we're responsible for establishing the connection to one of
@@ -743,8 +688,7 @@ namespace IceInternal
private Ice.ConnectionI createConnection(Transceiver transceiver, ConnectorInfo ci)
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(_pending.ContainsKey(ci.connector) && transceiver != null);
@@ -782,10 +726,6 @@ namespace IceInternal
_connectionsByEndpoint.Add(connection.endpoint().compress(true), connection);
return connection;
}
- finally
- {
- _m.Unlock();
- }
}
private void finishGetConnection(List<ConnectorInfo> connectors,
@@ -800,8 +740,7 @@ namespace IceInternal
}
HashSet<ConnectCallback> callbacks = new HashSet<ConnectCallback>();
- _m.Lock();
- try
+ lock(this)
{
foreach(ConnectorInfo c in connectors)
{
@@ -832,11 +771,7 @@ namespace IceInternal
{
cc.removeFromPending();
}
- _m.NotifyAll();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.PulseAll(this);
}
bool compress;
@@ -869,8 +804,7 @@ namespace IceInternal
}
HashSet<ConnectCallback> callbacks = new HashSet<ConnectCallback>();
- _m.Lock();
- try
+ lock(this)
{
foreach(ConnectorInfo c in connectors)
{
@@ -897,11 +831,7 @@ namespace IceInternal
Debug.Assert(!failedCallbacks.Contains(cc));
cc.removeFromPending();
}
- _m.NotifyAll();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.PulseAll(this);
}
foreach(ConnectCallback cc in callbacks)
@@ -1298,73 +1228,50 @@ namespace IceInternal
private Dictionary<Connector, HashSet<ConnectCallback>> _pending =
new Dictionary<Connector, HashSet<ConnectCallback>>();
private int _pendingConnectCount;
-
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
public sealed class IncomingConnectionFactory : EventHandler, Ice.ConnectionI.StartCallback
{
public void activate()
{
- _m.Lock();
- try
+ lock(this)
{
setState(StateActive);
}
- finally
- {
- _m.Unlock();
- }
}
public void hold()
{
- _m.Lock();
- try
+ lock(this)
{
setState(StateHolding);
}
- finally
- {
- _m.Unlock();
- }
}
public void destroy()
{
- _m.Lock();
- try
+ lock(this)
{
setState(StateClosed);
}
- finally
- {
- _m.Unlock();
- }
}
public void updateConnectionObservers()
{
- _m.Lock();
- try
+ lock(this)
{
foreach(Ice.ConnectionI connection in _connections)
{
connection.updateObserver();
}
}
- finally
- {
- _m.Unlock();
- }
}
public void waitUntilHolding()
{
ICollection<Ice.ConnectionI> connections;
- _m.Lock();
- try
+ lock(this)
{
//
// First we wait until the connection factory itself is in
@@ -1372,7 +1279,7 @@ namespace IceInternal
//
while(_state < StateHolding)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
//
@@ -1381,10 +1288,6 @@ namespace IceInternal
//
connections = new List<Ice.ConnectionI>(_connections);
}
- finally
- {
- _m.Unlock();
- }
//
// Now we wait until each connection is in holding state.
@@ -1399,8 +1302,7 @@ namespace IceInternal
{
ICollection<Ice.ConnectionI> connections = null;
- _m.Lock();
- try
+ lock(this)
{
//
// First we wait until the factory is destroyed. If we are using
@@ -1408,7 +1310,7 @@ namespace IceInternal
//
while(_state != StateFinished)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
//
@@ -1422,18 +1324,13 @@ namespace IceInternal
//
connections = new List<Ice.ConnectionI>(_connections);
}
- finally
- {
- _m.Unlock();
- }
foreach(Ice.ConnectionI connection in connections)
{
connection.waitUntilFinished();
}
- _m.Lock();
- try
+ lock(this)
{
if(_transceiver != null)
{
@@ -1452,10 +1349,6 @@ namespace IceInternal
_connections.Clear();
_monitor.destroy();
}
- finally
- {
- _m.Unlock();
- }
}
public EndpointI endpoint()
@@ -1466,8 +1359,7 @@ namespace IceInternal
public ICollection<Ice.ConnectionI> connections()
{
- _m.Lock();
- try
+ lock(this)
{
ICollection<Ice.ConnectionI> connections = new List<Ice.ConnectionI>();
@@ -1484,10 +1376,6 @@ namespace IceInternal
return connections;
}
- finally
- {
- _m.Unlock();
- }
}
public void flushAsyncBatchRequests(CommunicatorBatchOutgoingAsync outAsync)
@@ -1579,10 +1467,9 @@ namespace IceInternal
{
Ice.ConnectionI connection = null;
- ThreadPoolMessage msg = new ThreadPoolMessage(_m);
+ ThreadPoolMessage msg = new ThreadPoolMessage(this);
- _m.Lock();
- try
+ lock(this)
{
if(!msg.startIOScope(ref current))
{
@@ -1682,10 +1569,6 @@ namespace IceInternal
msg.finishIOScope(ref current);
}
}
- finally
- {
- _m.Unlock();
- }
Debug.Assert(connection != null);
connection.start(this);
@@ -1693,16 +1576,11 @@ namespace IceInternal
public override void finished(ref ThreadPoolCurrent current)
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(_state == StateClosed);
setState(StateFinished);
}
- finally
- {
- _m.Unlock();
- }
}
public override string ToString()
@@ -1721,8 +1599,7 @@ namespace IceInternal
//
public void connectionStartCompleted(Ice.ConnectionI connection)
{
- _m.Lock();
- try
+ lock(this)
{
//
// Initially, connections are in the holding state. If the factory is active
@@ -1733,16 +1610,11 @@ namespace IceInternal
connection.activate();
}
}
- finally
- {
- _m.Unlock();
- }
}
public void connectionStartFailed(Ice.ConnectionI connection, Ice.LocalException ex)
{
- _m.Lock();
- try
+ lock(this)
{
if(_state >= StateClosed)
{
@@ -1753,10 +1625,6 @@ namespace IceInternal
// Do not warn about connection exceptions here. The connection is not yet validated.
//
}
- finally
- {
- _m.Unlock();
- }
}
public IncomingConnectionFactory(Instance instance, EndpointI endpoint, Ice.ObjectAdapter adapter,
@@ -1939,7 +1807,7 @@ namespace IceInternal
}
_state = state;
- _m.NotifyAll();
+ System.Threading.Monitor.PulseAll(this);
}
private void warning(Ice.LocalException ex)
@@ -1962,8 +1830,6 @@ namespace IceInternal
private HashSet<Ice.ConnectionI> _connections;
private int _state;
-
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
}
diff --git a/cs/src/Ice/ConnectionI.cs b/cs/src/Ice/ConnectionI.cs
index b176fc37347..666c245f7c3 100644
--- a/cs/src/Ice/ConnectionI.cs
+++ b/cs/src/Ice/ConnectionI.cs
@@ -43,8 +43,7 @@ namespace Ice
{
try
{
- _m.Lock();
- try
+ lock(this)
{
//
// The connection might already be closed if the communicator was destroyed.
@@ -68,7 +67,7 @@ namespace Ice
//
while(_state <= StateNotValidated)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
if(_state >= StateClosing)
@@ -83,10 +82,6 @@ namespace Ice
//
setState(StateHolding);
}
- finally
- {
- _m.Unlock();
- }
}
catch(LocalException ex)
{
@@ -111,8 +106,7 @@ namespace Ice
public void activate()
{
- _m.Lock();
- try
+ lock(this)
{
if(_state <= StateNotValidated)
{
@@ -125,16 +119,11 @@ namespace Ice
}
setState(StateActive);
}
- finally
- {
- _m.Unlock();
- }
}
public void hold()
{
- _m.Lock();
- try
+ lock(this)
{
if(_state <= StateNotValidated)
{
@@ -143,10 +132,6 @@ namespace Ice
setState(StateHolding);
}
- finally
- {
- _m.Unlock();
- }
}
// DestructionReason.
@@ -155,8 +140,7 @@ namespace Ice
public void destroy(int reason)
{
- _m.Lock();
- try
+ lock(this)
{
switch(reason)
{
@@ -173,16 +157,11 @@ namespace Ice
}
}
}
- finally
- {
- _m.Unlock();
- }
}
public void close(bool force)
{
- _m.Lock();
- try
+ lock(this)
{
if(force)
{
@@ -199,29 +178,20 @@ namespace Ice
//
while(_requests.Count != 0 || _asyncRequests.Count != 0)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
setState(StateClosing, new CloseConnectionException());
}
}
- finally
- {
- _m.Unlock();
- }
}
public bool isActiveOrHolding()
{
- _m.Lock();
- try
+ lock(this)
{
return _state > StateNotValidated && _state < StateClosing;
}
- finally
- {
- _m.Unlock();
- }
}
public bool isFinished()
@@ -231,7 +201,7 @@ namespace Ice
// threads operating in this connection object, connection
// destruction is considered as not yet finished.
//
- if(!_m.TryLock())
+ if(!System.Threading.Monitor.TryEnter(this))
{
return false;
}
@@ -248,14 +218,13 @@ namespace Ice
}
finally
{
- _m.Unlock();
+ System.Threading.Monitor.Exit(this);
}
}
public void throwException()
{
- _m.Lock();
- try
+ lock(this)
{
if(_exception != null)
{
@@ -263,32 +232,22 @@ namespace Ice
throw _exception;
}
}
- finally
- {
- _m.Unlock();
- }
}
public void waitUntilHolding()
{
- _m.Lock();
- try
+ lock(this)
{
while(_state < StateHolding || _dispatchCount > 0)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
}
- finally
- {
- _m.Unlock();
- }
}
public void waitUntilFinished()
{
- _m.Lock();
- try
+ lock(this)
{
//
// We wait indefinitely until the connection is finished and all
@@ -298,7 +257,7 @@ namespace Ice
//
while(_state < StateFinished || _dispatchCount > 0)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
Debug.Assert(_state == StateFinished);
@@ -308,16 +267,11 @@ namespace Ice
//
_adapter = null;
}
- finally
- {
- _m.Unlock();
- }
}
public void updateObserver()
{
- _m.Lock();
- try
+ lock(this)
{
if(_state < StateNotValidated || _state > StateClosed)
{
@@ -339,16 +293,11 @@ namespace Ice
_readStreamPos = -1;
}
}
- finally
- {
- _m.Unlock();
- }
}
public void monitor(long now, IceInternal.ACMConfig acm)
{
- _m.Lock();
- try
+ lock(this)
{
if(_state != StateActive)
{
@@ -411,18 +360,13 @@ namespace Ice
}
}
}
- finally
- {
- _m.Unlock();
- }
}
public bool sendRequest(IceInternal.Outgoing og, bool compress, bool response)
{
IceInternal.BasicStream os = og.ostr();
- _m.Lock();
- try
+ lock(this)
{
if(_exception != null)
{
@@ -492,10 +436,6 @@ namespace Ice
return sent;
}
- finally
- {
- _m.Unlock();
- }
}
public bool sendAsyncRequest(IceInternal.OutgoingAsync og, bool compress, bool response,
@@ -503,8 +443,7 @@ namespace Ice
{
IceInternal.BasicStream os = og.ostr__;
- _m.Lock();
- try
+ lock(this)
{
if(_exception != null)
{
@@ -571,23 +510,18 @@ namespace Ice
}
return sent;
}
- finally
- {
- _m.Unlock();
- }
}
public void prepareBatchRequest(IceInternal.BasicStream os)
{
- _m.Lock();
- try
+ lock(this)
{
//
// Wait if flushing is currently in progress.
//
while(_batchStreamInUse && _exception == null)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
if(_exception != null)
@@ -632,18 +566,13 @@ namespace Ice
// finishBatchRequest() or abortBatchRequest() is called.
//
}
- finally
- {
- _m.Unlock();
- }
}
public void finishBatchRequest(IceInternal.BasicStream os, bool compress)
{
try
{
- _m.Lock();
- try
+ lock(this)
{
//
// Get the batch stream back.
@@ -758,11 +687,7 @@ namespace Ice
//
Debug.Assert(_batchStreamInUse);
_batchStreamInUse = false;
- _m.NotifyAll();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.PulseAll(this);
}
}
catch(LocalException)
@@ -774,8 +699,7 @@ namespace Ice
public void abortBatchRequest()
{
- _m.Lock();
- try
+ lock(this)
{
_batchStream = new IceInternal.BasicStream(_instance, Util.currentProtocolEncoding, _batchAutoFlush);
_batchRequestNum = 0;
@@ -784,11 +708,7 @@ namespace Ice
Debug.Assert(_batchStreamInUse);
_batchStreamInUse = false;
- _m.NotifyAll();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.PulseAll(this);
}
}
@@ -842,12 +762,11 @@ namespace Ice
public bool flushBatchRequests(IceInternal.BatchOutgoing @out)
{
- _m.Lock();
- try
+ lock(this)
{
while(_batchStreamInUse && _exception == null)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
if(_exception != null)
@@ -898,20 +817,15 @@ namespace Ice
return sent;
}
- finally
- {
- _m.Unlock();
- }
}
public bool flushAsyncBatchRequests(IceInternal.BatchOutgoingAsync outAsync, out Ice.AsyncCallback sentCallback)
{
- _m.Lock();
- try
+ lock(this)
{
while(_batchStreamInUse && _exception == null)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
if(_exception != null)
@@ -962,16 +876,11 @@ namespace Ice
_batchMarker = 0;
return sent;
}
- finally
- {
- _m.Unlock();
- }
}
public void setCallback(ConnectionCallback callback)
{
- _m.Lock();
- try
+ lock(this)
{
if(_state > StateClosing)
{
@@ -979,16 +888,11 @@ namespace Ice
}
_callback = callback;
}
- finally
- {
- _m.Unlock();
- }
}
public void setACM(Optional<int> timeout, Optional<ACMClose> close, Optional<ACMHeartbeat> heartbeat)
{
- _m.Lock();
- try
+ lock(this)
{
if(_monitor != null)
{
@@ -1012,29 +916,19 @@ namespace Ice
}
}
}
- finally
- {
- _m.Unlock();
- }
}
public ACM getACM()
{
- _m.Lock();
- try
+ lock(this)
{
return _monitor != null ? _monitor.getACM() : new ACM(0, ACMClose.CloseOff, ACMHeartbeat.HeartbeatOff);
}
- finally
- {
- _m.Unlock();
- }
}
public void requestTimedOut(IceInternal.OutgoingMessageCallback @out)
{
- _m.Lock();
- try
+ lock(this)
{
LinkedListNode<OutgoingMessage> p;
for(p = _sendStreams.First; p != null; p = p.Next)
@@ -1075,16 +969,11 @@ namespace Ice
}
}
}
- finally
- {
- _m.Unlock();
- }
}
public void asyncRequestTimedOut(IceInternal.OutgoingAsyncMessageCallback outAsync)
{
- _m.Lock();
- try
+ lock(this)
{
LinkedListNode<OutgoingMessage> p;
for(p = _sendStreams.First; p != null; p = p.Next)
@@ -1125,16 +1014,11 @@ namespace Ice
}
}
}
- finally
- {
- _m.Unlock();
- }
}
public void sendResponse(int requestId, IceInternal.BasicStream os, byte compressFlag)
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(_state > StateNotValidated);
@@ -1146,7 +1030,7 @@ namespace Ice
{
reap();
}
- _m.NotifyAll();
+ System.Threading.Monitor.PulseAll(this);
}
if(_state >= StateClosed)
@@ -1167,16 +1051,11 @@ namespace Ice
setState(StateClosed, ex);
}
}
- finally
- {
- _m.Unlock();
- }
}
public void sendNoResponse()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(_state > StateNotValidated);
@@ -1188,7 +1067,7 @@ namespace Ice
{
reap();
}
- _m.NotifyAll();
+ System.Threading.Monitor.PulseAll(this);
}
if(_state >= StateClosed)
@@ -1207,10 +1086,6 @@ namespace Ice
setState(StateClosed, ex);
}
}
- finally
- {
- _m.Unlock();
- }
}
public IceInternal.EndpointI endpoint()
@@ -1225,8 +1100,7 @@ namespace Ice
public void setAdapter(ObjectAdapter adapter)
{
- _m.Lock();
- try
+ lock(this)
{
if(_state <= StateNotValidated || _state >= StateClosing)
{
@@ -1253,23 +1127,14 @@ namespace Ice
// registered, even if we add or remove an object adapter.
//
}
- finally
- {
- _m.Unlock();
- }
}
public ObjectAdapter getAdapter()
{
- _m.Lock();
- try
+ lock(this)
{
return _adapter;
}
- finally
- {
- _m.Unlock();
- }
}
public Endpoint getEndpoint()
@@ -1365,9 +1230,8 @@ namespace Ice
Queue<OutgoingMessage> sentCBs = null;
MessageInfo info = new MessageInfo();
- IceInternal.ThreadPoolMessage msg = new IceInternal.ThreadPoolMessage(_m);
- _m.Lock();
- try
+ IceInternal.ThreadPoolMessage msg = new IceInternal.ThreadPoolMessage(this);
+ lock(this)
{
if(!msg.startIOScope(ref current))
{
@@ -1629,10 +1493,6 @@ namespace Ice
msg.destroy(ref c);
}, this);
}
- finally
- {
- _m.Unlock();
- }
}
private void dispatch(StartCallback startCB, Queue<OutgoingMessage> sentCBs, MessageInfo info)
@@ -1712,8 +1572,7 @@ namespace Ice
//
if(count > 0)
{
- _m.Lock();
- try
+ lock(this)
{
_dispatchCount -= count;
if(_dispatchCount == 0)
@@ -1739,28 +1598,19 @@ namespace Ice
{
reap();
}
- _m.NotifyAll();
+ System.Threading.Monitor.PulseAll(this);
}
}
- finally
- {
- _m.Unlock();
- }
}
}
public override void finished(ref IceInternal.ThreadPoolCurrent current)
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(_state == StateClosed);
unscheduleTimeout(IceInternal.SocketOperation.Read | IceInternal.SocketOperation.Write);
}
- finally
- {
- _m.Unlock();
- }
//
// If there are no callbacks to call, we don't call ioCompleted() since we're not going
@@ -1867,8 +1717,7 @@ namespace Ice
// This must be done last as this will cause waitUntilFinished() to return (and communicator
// objects such as the timer might be destroyed too).
//
- _m.Lock();
- try
+ lock(this)
{
setState(StateFinished);
if(_dispatchCount == 0)
@@ -1876,10 +1725,6 @@ namespace Ice
reap();
}
}
- finally
- {
- _m.Unlock();
- }
}
public override string ToString()
@@ -1889,8 +1734,7 @@ namespace Ice
public void timedOut()
{
- _m.Lock();
- try
+ lock(this)
{
if(_state <= StateNotValidated)
{
@@ -1905,10 +1749,6 @@ namespace Ice
setState(StateClosed, new CloseTimeoutException());
}
}
- finally
- {
- _m.Unlock();
- }
}
public string type()
@@ -1923,8 +1763,7 @@ namespace Ice
public ConnectionInfo getInfo()
{
- _m.Lock();
- try
+ lock(this)
{
if(_state >= StateClosed)
{
@@ -1932,10 +1771,6 @@ namespace Ice
}
return initConnectionInfo();
}
- finally
- {
- _m.Unlock();
- }
}
public string ice_toString_()
@@ -1945,15 +1780,10 @@ namespace Ice
public void exception(LocalException ex)
{
- _m.Lock();
- try
+ lock(this)
{
setState(StateClosed, ex);
}
- finally
- {
- _m.Unlock();
- }
}
public void invokeException(int requestId, LocalException ex, int invokeNum)
@@ -1963,8 +1793,7 @@ namespace Ice
// called in case of a fatal exception we decrement _dispatchCount here.
//
- _m.Lock();
- try
+ lock(this)
{
setState(StateClosed, ex);
@@ -1978,14 +1807,10 @@ namespace Ice
{
reap();
}
- _m.NotifyAll();
+ System.Threading.Monitor.PulseAll(this);
}
}
}
- finally
- {
- _m.Unlock();
- }
}
static ConnectionI()
@@ -2308,7 +2133,7 @@ namespace Ice
}
_state = state;
- _m.NotifyAll();
+ System.Threading.Monitor.PulseAll(this);
if(_state == StateClosing && _dispatchCount == 0)
{
@@ -2891,7 +2716,7 @@ namespace Ice
{
_requests.Remove(info.requestId);
og.finished(info.stream);
- _m.NotifyAll(); // Notify threads blocked in close(false)
+ System.Threading.Monitor.PulseAll(this); // Notify threads blocked in close(false)
}
else if(_asyncRequests.TryGetValue(info.requestId, out info.outAsync))
{
@@ -2914,7 +2739,7 @@ namespace Ice
{
++_dispatchCount;
}
- _m.NotifyAll(); // Notify threads blocked in close(false)
+ System.Threading.Monitor.PulseAll(this); // Notify threads blocked in close(false)
}
break;
}
@@ -3378,7 +3203,5 @@ namespace Ice
ConnectionState.ConnectionStateClosed, // StateClosed
ConnectionState.ConnectionStateClosed, // StateFinished
};
-
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
}
diff --git a/cs/src/Ice/EndpointHostResolver.cs b/cs/src/Ice/EndpointHostResolver.cs
index 5b2a14d1d5d..b5d8a62df9f 100644
--- a/cs/src/Ice/EndpointHostResolver.cs
+++ b/cs/src/Ice/EndpointHostResolver.cs
@@ -121,8 +121,7 @@ namespace IceInternal
}
}
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_destroyed);
@@ -144,26 +143,17 @@ namespace IceInternal
}
_queue.AddLast(entry);
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
public void destroy()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_destroyed);
_destroyed = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
@@ -182,12 +172,11 @@ namespace IceInternal
ResolveEntry r;
Ice.Instrumentation.ThreadObserver threadObserver;
- _m.Lock();
- try
+ lock(this)
{
while(!_destroyed && _queue.Count == 0)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
if(_destroyed)
@@ -199,10 +188,6 @@ namespace IceInternal
_queue.RemoveFirst();
threadObserver = _observer;
}
- finally
- {
- _m.Unlock();
- }
try
{
@@ -269,8 +254,7 @@ namespace IceInternal
public void
updateObserver()
{
- _m.Lock();
- try
+ lock(this)
{
Ice.Instrumentation.CommunicatorObserver obsv = _instance.getObserver();
if(obsv != null)
@@ -285,10 +269,6 @@ namespace IceInternal
}
}
}
- finally
- {
- _m.Unlock();
- }
}
private class ResolveEntry
@@ -359,8 +339,6 @@ namespace IceInternal
}
private HelperThread _thread;
-
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
}
#endif
diff --git a/cs/src/Ice/LocatorInfo.cs b/cs/src/Ice/LocatorInfo.cs
index 93526376709..97951c8df29 100644
--- a/cs/src/Ice/LocatorInfo.cs
+++ b/cs/src/Ice/LocatorInfo.cs
@@ -99,8 +99,7 @@ namespace IceInternal
public void
addCallback(Reference @ref, Reference wellKnownRef, int ttl, GetEndpointsCallback cb)
{
- _m.Lock();
- try
+ lock(this)
{
RequestCallback callback = new RequestCallback(@ref, ttl, cb);
if(_response)
@@ -126,17 +125,12 @@ namespace IceInternal
}
}
}
- finally
- {
- _m.Unlock();
- }
}
public EndpointI[]
getEndpoints(Reference @ref, Reference wellKnownRef, int ttl, out bool cached)
{
- _m.Lock();
- try
+ lock(this)
{
if(!_response || _exception == null)
{
@@ -153,7 +147,7 @@ namespace IceInternal
while(!_response && _exception == null)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
}
@@ -189,10 +183,6 @@ namespace IceInternal
}
return endpoints == null ? new EndpointI[0] : endpoints;
}
- finally
- {
- _m.Unlock();
- }
}
public Request(LocatorInfo locatorInfo, Reference @ref)
@@ -206,8 +196,7 @@ namespace IceInternal
public void
response(Ice.ObjectPrx proxy)
{
- _m.Lock();
- try
+ lock(this)
{
_locatorInfo.finishRequest(_ref, _wellKnownRefs, proxy, false);
_response = true;
@@ -216,19 +205,14 @@ namespace IceInternal
{
callback.response(_locatorInfo, proxy);
}
- _m.NotifyAll();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.PulseAll(this);
}
}
public void
exception(Ice.Exception ex)
{
- _m.Lock();
- try
+ lock(this)
{
_locatorInfo.finishRequest(_ref, _wellKnownRefs, null, ex is Ice.UserException);
_exception = ex;
@@ -236,11 +220,7 @@ namespace IceInternal
{
callback.exception(_locatorInfo, ex);
}
- _m.NotifyAll();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.PulseAll(this);
}
}
@@ -255,8 +235,6 @@ namespace IceInternal
private bool _response;
private Ice.ObjectPrx _proxy;
private Ice.Exception _exception;
-
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
private class ObjectRequest : Request
diff --git a/cs/src/Ice/Makefile b/cs/src/Ice/Makefile
index cb3d68a8069..3f1fa24b038 100644
--- a/cs/src/Ice/Makefile
+++ b/cs/src/Ice/Makefile
@@ -57,7 +57,6 @@ SRCS = Acceptor.cs \
LoggerPlugin.cs \
MetricsAdminI.cs \
MetricsObserverI.cs \
- Monitor.cs \
Network.cs \
ObjectAdapterFactory.cs \
ObjectAdapterI.cs \
diff --git a/cs/src/Ice/Makefile.mak b/cs/src/Ice/Makefile.mak
index ce76eed7d70..4ed3c510383 100644
--- a/cs/src/Ice/Makefile.mak
+++ b/cs/src/Ice/Makefile.mak
@@ -58,7 +58,6 @@ SRCS = Acceptor.cs \
LoggerPlugin.cs \
MetricsAdminI.cs \
MetricsObserverI.cs \
- Monitor.cs \
Network.cs \
ObjectAdapterFactory.cs \
ObjectAdapterI.cs \
diff --git a/cs/src/Ice/Monitor.cs b/cs/src/Ice/Monitor.cs
deleted file mode 100644
index 549b1dd0211..00000000000
--- a/cs/src/Ice/Monitor.cs
+++ /dev/null
@@ -1,290 +0,0 @@
-// **********************************************************************
-//
-// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
-//
-// This copy of Ice is licensed to you under the terms described in the
-// ICE_LICENSE file included in this distribution.
-//
-// **********************************************************************
-
-//
-// The System.Threading.Monitor class in the Compact Framework does not
-// support the Wait/Pulse/PulseAll methods, so we implement our own
-// Monitor here.
-//
-// For non-CF builds, our Monitor simply wraps the standard Monitor class.
-//
-// All code that uses a monitor for waiting/signaling must now use the
-// following locking style:
-//
-// IceUtilInternal.Monitor mon = new IceUtilInternal.Monitor();
-// mon.Lock();
-// try
-// {
-// // Wait or Notify ...
-// }
-// finally
-// {
-// mon.Unlock();
-// }
-//
-namespace IceUtilInternal
-{
-#if COMPACT
-
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
-
- public class Monitor
- {
- public Monitor()
- {
- _eventPool = null;
- _mutex = new System.Threading.Mutex();
- _lockCount = 0;
- }
-
- public void Lock()
- {
- _mutex.WaitOne();
- _lockCount++; // Keep track of recursive locks.
- }
-
- public void Unlock()
- {
- _lockCount--; // Keep track of recursive locks.
- _mutex.ReleaseMutex();
- }
-
- public bool TryLock()
- {
- bool result = _mutex.WaitOne(0, false);
- if(result)
- {
- _lockCount++; // Keep track of recursive locks.
- }
- return result;
- }
-
- public void Wait()
- {
- if(_waitQueue == null)
- {
- _waitQueue = new Queue<LockerEvent>();
- }
-
- LockerEvent e = acquireEvent();
- try
- {
- _waitQueue.Enqueue(e);
-
- //
- // Preserve the lock count until we reaquire the lock.
- //
- int lockCount = _lockCount;
- _lockCount = 0;
-
- //
- // Fully release the lock.
- //
- for(int i = 0; i < lockCount; ++i)
- {
- _mutex.ReleaseMutex();
- }
-
- //
- // Wait for the event to be set.
- //
- e.ev.WaitOne();
-
- //
- // Reacquire the lock the same number of times.
- //
- for(int i = 0; i < lockCount; ++i)
- {
- _mutex.WaitOne();
- }
-
- _lockCount = lockCount;
-
- Debug.Assert(e.notified);
- }
- finally
- {
- releaseEvent(e);
- }
- }
-
- public bool TimedWait(int timeout)
- {
- if(_waitQueue == null)
- {
- _waitQueue = new Queue<LockerEvent>();
- }
-
- LockerEvent e = acquireEvent();
- try
- {
- _waitQueue.Enqueue(e);
-
- //
- // Preserve the lock count until we reaquire the lock.
- //
- int lockCount = _lockCount;
- _lockCount = 0;
-
- //
- // Fully release the lock.
- //
- for(int i = 0; i < lockCount; ++i)
- {
- _mutex.ReleaseMutex();
- }
-
- //
- // Wait for the event to be set or the timeout to expire.
- //
- e.ev.WaitOne(timeout, false);
-
- //
- // Reacquire the lock the same number of times.
- //
- for(int i = 0; i < lockCount; ++i)
- {
- _mutex.WaitOne();
- }
-
- _lockCount = lockCount;
- return e.notified;
- }
- finally
- {
- releaseEvent(e);
- }
- }
-
- public void Notify()
- {
- if(_waitQueue != null)
- {
- while(_waitQueue.Count > 0)
- {
- //
- // Set the first event in the wait queue.
- //
- LockerEvent h = _waitQueue.Dequeue();
- h.notified = true;
- h.ev.Set();
- }
- }
- }
-
- public void NotifyAll()
- {
- if(_waitQueue != null)
- {
- //
- // Set all the events in the wait queue.
- //
- foreach(LockerEvent h in _waitQueue)
- {
- h.notified = true;
- h.ev.Set();
- }
- _waitQueue.Clear();
- }
- }
-
- private LockerEvent acquireEvent()
- {
- if(_eventPool == null)
- {
- return new LockerEvent();
- }
- else
- {
- LockerEvent l = _eventPool;
- _eventPool = _eventPool.next;
- l.Reset();
- l.next = null;
- return l;
- }
- }
-
- private void releaseEvent(LockerEvent e)
- {
- e.next = _eventPool;
- _eventPool = e;
- }
-
- internal class LockerEvent
- {
- internal System.Threading.EventWaitHandle ev;
- internal bool notified;
- internal LockerEvent next;
-
- internal LockerEvent()
- {
- ev = new System.Threading.ManualResetEvent(false);
- next = null;
- }
-
- internal void Reset()
- {
- ev.Reset();
- notified = false;
- }
- }
-
- private Queue<LockerEvent> _waitQueue;
- private LockerEvent _eventPool;
- private System.Threading.Mutex _mutex;
- private int _lockCount;
- }
-
-#else
-
- //
- // This implementation is just a wrapper around System.Threading.Monitor.
- //
- public class Monitor
- {
- public void Lock()
- {
- System.Threading.Monitor.Enter(this);
- }
-
- public void Unlock()
- {
- System.Threading.Monitor.Exit(this);
- }
-
- public bool TryLock()
- {
- return System.Threading.Monitor.TryEnter(this);
- }
-
- public void Wait()
- {
- System.Threading.Monitor.Wait(this);
- }
-
- public bool TimedWait(int timeout)
- {
- return System.Threading.Monitor.Wait(this, timeout);
- }
-
- public void Notify()
- {
- System.Threading.Monitor.Pulse(this);
- }
-
- public void NotifyAll()
- {
- System.Threading.Monitor.PulseAll(this);
- }
- }
-
-#endif
-}
diff --git a/cs/src/Ice/Network.cs b/cs/src/Ice/Network.cs
index b17d3535285..3b56909187e 100644
--- a/cs/src/Ice/Network.cs
+++ b/cs/src/Ice/Network.cs
@@ -651,14 +651,19 @@ namespace IceInternal
if(group.AddressFamily == AddressFamily.InterNetwork)
{
MulticastOption option;
+#if COMPACT
+ option = new MulticastOption(group);
+#else
if(index == -1)
{
option = new MulticastOption(group);
}
+
else
{
option = new MulticastOption(group, index);
}
+#endif
s.SetSocketOption(SocketOptionLevel.IP, SocketOptionName.AddMembership, option);
}
else
@@ -724,6 +729,7 @@ namespace IceInternal
public static void doListen(Socket socket, int backlog)
{
+
repeatListen:
try
@@ -1333,6 +1339,7 @@ namespace IceInternal
{
}
+//#if !COMPACT && !SILVERLIGHT && !UNITY
#if !COMPACT && !SILVERLIGHT && !UNITY
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
try
diff --git a/cs/src/Ice/ObjectAdapterFactory.cs b/cs/src/Ice/ObjectAdapterFactory.cs
index 326ae7e35b6..3dd791b1030 100644
--- a/cs/src/Ice/ObjectAdapterFactory.cs
+++ b/cs/src/Ice/ObjectAdapterFactory.cs
@@ -19,8 +19,7 @@ namespace IceInternal
public void shutdown()
{
List<Ice.ObjectAdapterI> adapters;
- _m.Lock();
- try
+ lock(this)
{
//
// Ignore shutdown requests if the object adapter factory has
@@ -36,11 +35,7 @@ namespace IceInternal
instance_ = null;
_communicator = null;
- _m.NotifyAll();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.PulseAll(this);
}
//
@@ -56,23 +51,18 @@ namespace IceInternal
public void waitForShutdown()
{
List<Ice.ObjectAdapterI> adapters;
- _m.Lock();
- try
+ lock(this)
{
//
// First we wait for the shutdown of the factory itself.
//
while(instance_ != null)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
adapters = new List<Ice.ObjectAdapterI>(_adapters);
}
- finally
- {
- _m.Unlock();
- }
//
// Now we wait for deactivation of each object adapter.
@@ -85,15 +75,10 @@ namespace IceInternal
public bool isShutdown()
{
- _m.Lock();
- try
+ lock(this)
{
return instance_ == null;
}
- finally
- {
- _m.Unlock();
- }
}
public void destroy()
@@ -104,45 +89,30 @@ namespace IceInternal
waitForShutdown();
List<Ice.ObjectAdapterI> adapters;
- _m.Lock();
- try
+ lock(this)
{
adapters = new List<Ice.ObjectAdapterI>(_adapters);
}
- finally
- {
- _m.Unlock();
- }
foreach(Ice.ObjectAdapter adapter in adapters)
{
adapter.destroy();
}
- _m.Lock();
- try
+ lock(this)
{
_adapters.Clear();
}
- finally
- {
- _m.Unlock();
- }
}
public void
updateConnectionObservers()
{
List<Ice.ObjectAdapterI> adapters;
- _m.Lock();
- try
+ lock(this)
{
adapters = new List<Ice.ObjectAdapterI>(_adapters);
}
- finally
- {
- _m.Unlock();
- }
foreach(Ice.ObjectAdapterI adapter in adapters)
{
@@ -154,15 +124,10 @@ namespace IceInternal
updateThreadObservers()
{
List<Ice.ObjectAdapterI> adapters;
- _m.Lock();
- try
+ lock(this)
{
adapters = new List<Ice.ObjectAdapterI>(_adapters);
}
- finally
- {
- _m.Unlock();
- }
foreach(Ice.ObjectAdapterI adapter in adapters)
{
@@ -172,8 +137,7 @@ namespace IceInternal
public Ice.ObjectAdapter createObjectAdapter(string name, Ice.RouterPrx router)
{
- _m.Lock();
- try
+ lock(this)
{
if(instance_ == null)
{
@@ -201,17 +165,12 @@ namespace IceInternal
_adapters.Add(adapter);
return adapter;
}
- finally
- {
- _m.Unlock();
- }
}
public Ice.ObjectAdapter findObjectAdapter(Ice.ObjectPrx proxy)
{
List<Ice.ObjectAdapterI> adapters;
- _m.Lock();
- try
+ lock(this)
{
if(instance_ == null)
{
@@ -220,10 +179,6 @@ namespace IceInternal
adapters = new List<Ice.ObjectAdapterI>(_adapters);
}
- finally
- {
- _m.Unlock();
- }
foreach(Ice.ObjectAdapterI adapter in adapters)
{
@@ -245,8 +200,7 @@ namespace IceInternal
public void removeObjectAdapter(Ice.ObjectAdapterI adapter)
{
- _m.Lock();
- try
+ lock(this)
{
if(instance_ == null)
{
@@ -256,24 +210,15 @@ namespace IceInternal
_adapters.Remove(adapter);
_adapterNamesInUse.Remove(adapter.getName());
}
- finally
- {
- _m.Unlock();
- }
}
public void flushAsyncBatchRequests(CommunicatorBatchOutgoingAsync outAsync)
{
List<Ice.ObjectAdapterI> adapters;
- _m.Lock();
- try
+ lock(this)
{
adapters = new List<Ice.ObjectAdapterI>(_adapters);
}
- finally
- {
- _m.Unlock();
- }
foreach(Ice.ObjectAdapterI adapter in adapters)
{
@@ -296,8 +241,6 @@ namespace IceInternal
private Ice.Communicator _communicator;
private HashSet<string> _adapterNamesInUse;
private List<Ice.ObjectAdapterI> _adapters;
-
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
}
diff --git a/cs/src/Ice/ObjectAdapterI.cs b/cs/src/Ice/ObjectAdapterI.cs
index bb39f6f02bf..6870fa8e861 100644
--- a/cs/src/Ice/ObjectAdapterI.cs
+++ b/cs/src/Ice/ObjectAdapterI.cs
@@ -36,8 +36,7 @@ namespace Ice
bool registerProcess = false;
bool printAdapterReady = false;
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
@@ -78,10 +77,6 @@ namespace Ice
printAdapterReady = properties.getPropertyAsInt("Ice.PrintAdapterReady") > 0;
}
}
- finally
- {
- _m.Unlock();
- }
try
{
@@ -97,15 +92,10 @@ namespace Ice
// allow to user code to retry activating the adapter
// later.
//
- _m.Lock();
- try
+ lock(this)
{
_waitForActivate = false;
- _m.NotifyAll();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.PulseAll(this);
}
throw;
}
@@ -115,8 +105,7 @@ namespace Ice
System.Console.Out.WriteLine(_name + " ready");
}
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_deactivated); // Not possible if _waitForActivate = true;
@@ -124,7 +113,7 @@ namespace Ice
// Signal threads waiting for the activation.
//
_waitForActivate = false;
- _m.NotifyAll();
+ System.Threading.Monitor.PulseAll(this);
_activateOneOffDone = true;
@@ -133,16 +122,11 @@ namespace Ice
icf.activate();
}
}
- finally
- {
- _m.Unlock();
- }
}
public void hold()
{
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
@@ -151,10 +135,6 @@ namespace Ice
factory.hold();
}
}
- finally
- {
- _m.Unlock();
- }
}
public void waitForHold()
@@ -162,8 +142,7 @@ namespace Ice
while(true)
{
List<IceInternal.IncomingConnectionFactory> incomingConnectionFactories;
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
@@ -172,22 +151,17 @@ namespace Ice
++_waitForHold;
}
- finally
- {
- _m.Unlock();
- }
foreach(IceInternal.IncomingConnectionFactory factory in incomingConnectionFactories)
{
factory.waitUntilHolding();
}
- _m.Lock();
- try
+ lock(this)
{
if(--_waitForHold == 0)
{
- _m.NotifyAll();
+ System.Threading.Monitor.PulseAll(this);
}
//
@@ -207,15 +181,11 @@ namespace Ice
while(_waitForHold > 0)
{
checkForDeactivation();
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_waitForHoldRetry = false;
}
}
- finally
- {
- _m.Unlock();
- }
}
}
@@ -225,8 +195,7 @@ namespace Ice
List<IceInternal.IncomingConnectionFactory> incomingConnectionFactories;
IceInternal.LocatorInfo locatorInfo;
- _m.Lock();
- try
+ lock(this)
{
//
// Ignore deactivation requests if the object adapter has
@@ -244,7 +213,7 @@ namespace Ice
//
while(_waitForActivate)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
if(_routerInfo != null)
@@ -266,11 +235,7 @@ namespace Ice
locatorInfo = _locatorInfo;
_deactivated = true;
- _m.NotifyAll();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.PulseAll(this);
}
try
@@ -306,8 +271,7 @@ namespace Ice
public void waitForDeactivate()
{
IceInternal.IncomingConnectionFactory[] incomingConnectionFactories = null;
- _m.Lock();
- try
+ lock(this)
{
if(_destroyed)
{
@@ -321,15 +285,11 @@ namespace Ice
//
while(!_deactivated || _directCount > 0)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
incomingConnectionFactories = _incomingConnectionFactories.ToArray();
}
- finally
- {
- _m.Unlock();
- }
//
// Now we wait for until all incoming connection factories are
@@ -343,21 +303,15 @@ namespace Ice
public bool isDeactivated()
{
- _m.Lock();
- try
+ lock(this)
{
return _deactivated;
}
- finally
- {
- _m.Unlock();
- }
}
public void destroy()
{
- _m.Lock();
- try
+ lock(this)
{
//
// Another thread is in the process of destroying the object
@@ -365,7 +319,7 @@ namespace Ice
//
while(_destroying)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
//
@@ -378,10 +332,6 @@ namespace Ice
_destroying = true;
}
- finally
- {
- _m.Unlock();
- }
//
// Deactivate and wait for completion.
@@ -406,15 +356,14 @@ namespace Ice
IceInternal.ObjectAdapterFactory objectAdapterFactory;
- _m.Lock();
- try
+ lock(this)
{
//
// Signal that destroying is complete.
//
_destroying = false;
_destroyed = true;
- _m.NotifyAll();
+ System.Threading.Monitor.PulseAll(this);
//
// We're done, now we can throw away all incoming connection
@@ -436,10 +385,6 @@ namespace Ice
objectAdapterFactory = _objectAdapterFactory;
_objectAdapterFactory = null;
}
- finally
- {
- _m.Unlock();
- }
if(objectAdapterFactory != null)
{
@@ -454,8 +399,7 @@ namespace Ice
public ObjectPrx addFacet(Ice.Object obj, Identity ident, string facet)
{
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
checkIdentity(ident);
@@ -473,10 +417,6 @@ namespace Ice
return newProxy(id, facet);
}
- finally
- {
- _m.Unlock();
- }
}
public ObjectPrx addWithUUID(Ice.Object obj)
@@ -497,17 +437,12 @@ namespace Ice
{
checkServant(servant);
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
_servantManager.addDefaultServant(servant, category);
}
- finally
- {
- _m.Unlock();
- }
}
public Ice.Object remove(Identity ident)
@@ -517,49 +452,34 @@ namespace Ice
public Ice.Object removeFacet(Identity ident, string facet)
{
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
checkIdentity(ident);
return _servantManager.removeServant(ident, facet);
}
- finally
- {
- _m.Unlock();
- }
}
public Dictionary<string, Ice.Object> removeAllFacets(Identity ident)
{
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
checkIdentity(ident);
return _servantManager.removeAllFacets(ident);
}
- finally
- {
- _m.Unlock();
- }
}
public Ice.Object removeDefaultServant(string category)
{
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
return _servantManager.removeDefaultServant(category);
}
- finally
- {
- _m.Unlock();
- }
}
public Ice.Object find(Identity ident)
@@ -569,173 +489,118 @@ namespace Ice
public Ice.Object findFacet(Identity ident, string facet)
{
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
checkIdentity(ident);
return _servantManager.findServant(ident, facet);
}
- finally
- {
- _m.Unlock();
- }
}
public Dictionary<string, Ice.Object> findAllFacets(Identity ident)
{
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
checkIdentity(ident);
return _servantManager.findAllFacets(ident);
}
- finally
- {
- _m.Unlock();
- }
}
public Ice.Object findByProxy(ObjectPrx proxy)
{
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
IceInternal.Reference @ref = ((ObjectPrxHelperBase)proxy).reference__();
return findFacet(@ref.getIdentity(), @ref.getFacet());
}
- finally
- {
- _m.Unlock();
- }
}
public Ice.Object findDefaultServant(string category)
{
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
return _servantManager.findDefaultServant(category);
}
- finally
- {
- _m.Unlock();
- }
}
public void addServantLocator(ServantLocator locator, string prefix)
{
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
_servantManager.addServantLocator(locator, prefix);
}
- finally
- {
- _m.Unlock();
- }
}
public ServantLocator removeServantLocator(string prefix)
{
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
return _servantManager.removeServantLocator(prefix);
}
- finally
- {
- _m.Unlock();
- }
}
public ServantLocator findServantLocator(string prefix)
{
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
return _servantManager.findServantLocator(prefix);
}
- finally
- {
- _m.Unlock();
- }
}
public ObjectPrx createProxy(Identity ident)
{
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
checkIdentity(ident);
return newProxy(ident, "");
}
- finally
- {
- _m.Unlock();
- }
}
public ObjectPrx createDirectProxy(Identity ident)
{
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
checkIdentity(ident);
return newDirectProxy(ident, "");
}
- finally
- {
- _m.Unlock();
- }
}
public ObjectPrx createIndirectProxy(Identity ident)
{
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
checkIdentity(ident);
return newIndirectProxy(ident, "", _id);
}
- finally
- {
- _m.Unlock();
- }
}
public void setLocator(LocatorPrx locator)
{
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
_locatorInfo = instance_.locatorManager().get(locator);
}
- finally
- {
- _m.Unlock();
- }
}
public void refreshPublishedEndpoints()
@@ -744,8 +609,7 @@ namespace Ice
bool registerProcess = false;
List<IceInternal.EndpointI> oldPublishedEndpoints;
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
@@ -759,10 +623,6 @@ namespace Ice
instance_.initializationData().properties.getPropertyAsInt(_name + ".RegisterProcess") > 0;
}
}
- finally
- {
- _m.Unlock();
- }
try
{
@@ -772,8 +632,7 @@ namespace Ice
}
catch(Ice.LocalException)
{
- _m.Lock();
- try
+ lock(this)
{
//
// Restore the old published endpoints.
@@ -781,17 +640,12 @@ namespace Ice
_publishedEndpoints = oldPublishedEndpoints;
throw;
}
- finally
- {
- _m.Unlock();
- }
}
}
public Endpoint[] getEndpoints()
{
- _m.Lock();
- try
+ lock(this)
{
List<Endpoint> endpoints = new List<Endpoint>();
foreach(IceInternal.IncomingConnectionFactory factory in _incomingConnectionFactories)
@@ -800,23 +654,14 @@ namespace Ice
}
return endpoints.ToArray();
}
- finally
- {
- _m.Unlock();
- }
}
public Endpoint[] getPublishedEndpoints()
{
- _m.Lock();
- try
+ lock(this)
{
return _publishedEndpoints.ToArray();
}
- finally
- {
- _m.Unlock();
- }
}
public bool isLocal(ObjectPrx proxy)
@@ -847,8 +692,7 @@ namespace Ice
{
IceInternal.EndpointI[] endpoints = r.getEndpoints();
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
@@ -896,25 +740,16 @@ namespace Ice
return false;
}
- finally
- {
- _m.Unlock();
- }
}
}
public void flushAsyncBatchRequests(IceInternal.CommunicatorBatchOutgoingAsync outAsync)
{
List<IceInternal.IncomingConnectionFactory> f;
- _m.Lock();
- try
+ lock(this)
{
f = new List<IceInternal.IncomingConnectionFactory>(_incomingConnectionFactories);
}
- finally
- {
- _m.Unlock();
- }
foreach(IceInternal.IncomingConnectionFactory factory in f)
{
@@ -925,15 +760,10 @@ namespace Ice
public void updateConnectionObservers()
{
List<IceInternal.IncomingConnectionFactory> f;
- _m.Lock();
- try
+ lock(this)
{
f = new List<IceInternal.IncomingConnectionFactory>(_incomingConnectionFactories);
}
- finally
- {
- _m.Unlock();
- }
foreach(IceInternal.IncomingConnectionFactory p in f)
{
@@ -944,15 +774,10 @@ namespace Ice
public void updateThreadObservers()
{
IceInternal.ThreadPool threadPool = null;
- _m.Lock();
- try
+ lock(this)
{
threadPool = _threadPool;
}
- finally
- {
- _m.Unlock();
- }
if(threadPool != null)
{
@@ -962,24 +787,18 @@ namespace Ice
public void incDirectCount()
{
- _m.Lock();
- try
+ lock(this)
{
checkForDeactivation();
Debug.Assert(_directCount >= 0);
++_directCount;
}
- finally
- {
- _m.Unlock();
- }
}
public void decDirectCount()
{
- _m.Lock();
- try
+ lock(this)
{
// Not check for deactivation here!
@@ -988,13 +807,9 @@ namespace Ice
Debug.Assert(_directCount > 0);
if(--_directCount == 0)
{
- _m.NotifyAll();
+ System.Threading.Monitor.PulseAll(this);
}
}
- finally
- {
- _m.Unlock();
- }
}
public IceInternal.ThreadPool getThreadPool()
@@ -1634,8 +1449,7 @@ namespace Ice
if(registerProcess && serverId.Length > 0)
{
- _m.Lock();
- try
+ lock(this)
{
if(_processId == null)
{
@@ -1643,10 +1457,6 @@ namespace Ice
_processId = addWithUUID(servant).ice_getIdentity();
}
}
- finally
- {
- _m.Unlock();
- }
try
{
@@ -1795,7 +1605,5 @@ namespace Ice
private bool _destroyed;
private bool _noConfig;
private Identity _processId;
-
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
}
diff --git a/cs/src/Ice/Outgoing.cs b/cs/src/Ice/Outgoing.cs
index 2abc29f5969..dbf5b15dd90 100644
--- a/cs/src/Ice/Outgoing.cs
+++ b/cs/src/Ice/Outgoing.cs
@@ -110,8 +110,7 @@ namespace IceInternal
}
bool timedOut = false;
- _m.Lock();
- try
+ lock(this)
{
//
// If the handler says it's not finished, we wait until we're done.
@@ -124,7 +123,7 @@ namespace IceInternal
long deadline = now + invocationTimeout;
while((_state == StateInProgress || !_sent) && _state != StateFailed && !timedOut)
{
- _m.TimedWait((int)(deadline - now));
+ System.Threading.Monitor.Wait(this, (int)(deadline - now));
if((_state == StateInProgress || !_sent) && _state != StateFailed)
{
@@ -137,14 +136,10 @@ namespace IceInternal
{
while((_state == StateInProgress || !_sent) && _state != StateFailed)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
}
}
- finally
- {
- _m.Unlock();
- }
if(timedOut)
{
@@ -155,18 +150,13 @@ namespace IceInternal
// the timeout if there was a failure shortly before requestTimedOut got called.
// In this case, the exception should be set on the Outgoing.
//
- _m.Lock();
- try
+ lock(this)
{
while(_exception == null)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
}
- finally
- {
- _m.Unlock();
- }
}
if(_exception != null)
@@ -240,8 +230,7 @@ namespace IceInternal
public void sent()
{
- _m.Lock();
- try
+ lock(this)
{
if(_proxy.reference__().getMode() != Reference.Mode.ModeTwoway)
{
@@ -253,18 +242,13 @@ namespace IceInternal
_state = StateOK;
}
_sent = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
public void finished(BasicStream istr)
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(_proxy.reference__().getMode() == Reference.Mode.ModeTwoway); // Only for twoways.
@@ -409,18 +393,13 @@ namespace IceInternal
}
}
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
public void finished(Ice.Exception ex)
{
- _m.Lock();
- try
+ lock(this)
{
//Debug.Assert(_state <= StateInProgress);
if(_state > StateInProgress)
@@ -434,7 +413,7 @@ namespace IceInternal
//
Debug.Assert(_state != StateFailed);
_sent = true;
- _m.Notify();
+ System.Threading.Monitor.Pulse(this);
return;
}
@@ -446,11 +425,7 @@ namespace IceInternal
}
_state = StateFailed;
_exception = ex;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
@@ -672,8 +647,6 @@ namespace IceInternal
private InvocationObserver _observer;
private ChildInvocationObserver _childObserver;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
-
private static Dictionary<string, string> _emptyContext = new Dictionary<string, string>();
public Outgoing next; // For use by Ice.ObjectPrxHelperBase
@@ -708,22 +681,17 @@ namespace IceInternal
{
return;
}
- _m.Lock();
- try
+ lock(this)
{
while(_exception == null && !_sent)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
if(_exception != null)
{
throw _exception;
}
}
- finally
- {
- _m.Unlock();
- }
return;
}
@@ -737,8 +705,7 @@ namespace IceInternal
}
bool timedOut = false;
- _m.Lock();
- try
+ lock(this)
{
int timeout = _proxy.reference__().getInvocationTimeout();
if(timeout > 0)
@@ -747,7 +714,7 @@ namespace IceInternal
long deadline = now + timeout;
while(_exception == null && !_sent && !timedOut)
{
- _m.TimedWait((int)(deadline - now));
+ System.Threading.Monitor.Wait(this, (int)(deadline - now));
if(_exception == null && !_sent)
{
now = Time.currentMonotonicTimeMillis();
@@ -759,31 +726,22 @@ namespace IceInternal
{
while(_exception == null && !_sent)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
}
}
- finally
- {
- _m.Unlock();
- }
if(timedOut)
{
handler.requestTimedOut(this);
- _m.Lock();
- try
+ lock(this)
{
while(_exception == null)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
}
- finally
- {
- _m.Unlock();
- }
}
if(_exception != null)
@@ -824,8 +782,7 @@ namespace IceInternal
public void sent()
{
- _m.Lock();
- try
+ lock(this)
{
if(_childObserver != null)
{
@@ -833,30 +790,22 @@ namespace IceInternal
_childObserver = null;
}
_sent = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
public void finished(Ice.Exception ex)
{
- _m.Lock();
- if(_childObserver != null)
- {
- _childObserver.failed(ex.ice_name());
- _childObserver.detach();
- }
- try
+ lock(this)
{
+ if(_childObserver != null)
+ {
+ _childObserver.failed(ex.ice_name());
+ _childObserver.detach();
+ }
+
_exception = ex;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
@@ -898,7 +847,5 @@ namespace IceInternal
private InvocationObserver _observer;
private Observer _childObserver;
-
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
}
diff --git a/cs/src/Ice/OutgoingAsync.cs b/cs/src/Ice/OutgoingAsync.cs
index 23429c9fc19..7752bf7debb 100644
--- a/cs/src/Ice/OutgoingAsync.cs
+++ b/cs/src/Ice/OutgoingAsync.cs
@@ -149,76 +149,51 @@ namespace IceInternal
public bool isCompleted_()
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
return (state_ & Done) != 0;
}
- finally
- {
- monitor_.Unlock();
- }
}
public void waitForCompleted()
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
while((state_ & Done) == 0)
{
- monitor_.Wait();
+ System.Threading.Monitor.Wait(monitor_);
}
}
- finally
- {
- monitor_.Unlock();
- }
}
public bool isSent()
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
return (state_ & Sent) != 0;
}
- finally
- {
- monitor_.Unlock();
- }
}
public void waitForSent()
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
while((state_ & Sent) == 0 && exception_ == null)
{
- monitor_.Wait();
+ System.Threading.Monitor.Wait(monitor_);
}
}
- finally
- {
- monitor_.Unlock();
- }
}
public void throwLocalException()
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
if(exception_ != null)
{
throw exception_;
}
}
- finally
- {
- monitor_.Unlock();
- }
}
public bool sentSynchronously()
@@ -262,8 +237,7 @@ namespace IceInternal
{
get
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
if(waitHandle_ == null)
{
@@ -279,17 +253,12 @@ namespace IceInternal
}
return waitHandle_;
}
- finally
- {
- monitor_.Unlock();
- }
}
}
public Ice.AsyncResult whenSent(Ice.AsyncCallback cb)
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
if(cb == null)
{
@@ -305,10 +274,6 @@ namespace IceInternal
return this;
}
}
- finally
- {
- monitor_.Unlock();
- }
if(sentSynchronously_)
{
@@ -340,8 +305,7 @@ namespace IceInternal
public Ice.AsyncResult whenSent(Ice.SentCallback cb)
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
if(cb == null)
{
@@ -360,10 +324,6 @@ namespace IceInternal
return this;
}
}
- finally
- {
- monitor_.Unlock();
- }
if(sentSynchronously_)
{
@@ -395,8 +355,7 @@ namespace IceInternal
public Ice.AsyncResult whenCompletedWithAsyncCallback(Ice.AsyncCallback cb)
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
setCompletedCallback(cb);
if((state_ & Done) == 0)
@@ -408,10 +367,6 @@ namespace IceInternal
return this;
}
}
- finally
- {
- monitor_.Unlock();
- }
instance_.clientThreadPool().dispatch(() =>
{
@@ -429,8 +384,7 @@ namespace IceInternal
public Ice.AsyncResult whenCompleted(Ice.ExceptionCallback cb)
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
if(cb == null)
{
@@ -447,10 +401,6 @@ namespace IceInternal
return this;
}
}
- finally
- {
- monitor_.Unlock();
- }
instance_.clientThreadPool().dispatch(() =>
{
@@ -481,8 +431,7 @@ namespace IceInternal
public bool wait__()
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
if((state_ & EndCalled) != 0)
{
@@ -491,7 +440,7 @@ namespace IceInternal
state_ |= EndCalled;
while((state_ & Done) == 0)
{
- monitor_.Wait();
+ System.Threading.Monitor.Wait(monitor_);
}
if(exception_ != null)
{
@@ -499,10 +448,6 @@ namespace IceInternal
}
return (state_ & OK) != 0;
}
- finally
- {
- monitor_.Unlock();
- }
}
public void throwUserException__()
@@ -724,23 +669,18 @@ namespace IceInternal
protected void invokeException__(Ice.Exception ex)
{
Ice.AsyncCallback cb;
- monitor_.Lock();
- try
+ lock(monitor_)
{
state_ |= Done;
os_.resize(0, false); // Clear buffer now, instead of waiting for AsyncResult deallocation
exception_ = ex;
- monitor_.NotifyAll();
+ System.Threading.Monitor.PulseAll(monitor_);
if(waitHandle_ != null)
{
waitHandle_.Set();
}
cb = completedCallback_;
}
- finally
- {
- monitor_.Unlock();
- }
if(cb != null)
{
@@ -783,17 +723,12 @@ namespace IceInternal
protected void runTimerTask__()
{
IceInternal.RequestHandler handler;
- monitor_.Lock();
- try
+ lock(monitor_)
{
handler = timeoutRequestHandler_;
timeoutRequestHandler_ = null;
}
- finally
- {
- monitor_.Unlock();
- }
if(handler != null)
{
@@ -814,7 +749,7 @@ namespace IceInternal
protected string operation_;
protected Ice.Connection cachedConnection_;
- protected readonly IceUtilInternal.Monitor monitor_ = new IceUtilInternal.Monitor();
+ protected readonly object monitor_ = new object();
protected IceInternal.BasicStream is_;
protected IceInternal.BasicStream os_;
@@ -944,8 +879,7 @@ namespace IceInternal
public Ice.AsyncCallback sent__()
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
bool alreadySent = (state_ & Sent) != 0;
state_ |= Sent;
@@ -971,13 +905,9 @@ namespace IceInternal
waitHandle_.Set();
}
}
- monitor_.NotifyAll();
+ System.Threading.Monitor.PulseAll(monitor_);
return alreadySent ? null : sentCallback_; // Don't call the sent call is already sent.
}
- finally
- {
- monitor_.Unlock();
- }
}
public new void invokeSent__(Ice.AsyncCallback cb)
@@ -987,8 +917,7 @@ namespace IceInternal
public void finished__(Ice.Exception exc)
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
Debug.Assert((state_ & Done) == 0);
if(childObserver_ != null)
@@ -1003,10 +932,6 @@ namespace IceInternal
timeoutRequestHandler_ = null;
}
}
- finally
- {
- monitor_.Unlock();
- }
//
// NOTE: at this point, synchronization isn't needed, no other threads should be
@@ -1048,8 +973,7 @@ namespace IceInternal
Ice.AsyncCallback cb = null;
try
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
Debug.Assert(exception_ == null && (state_ & Done) == 0);
Debug.Assert(is_ != null);
@@ -1197,11 +1121,7 @@ namespace IceInternal
state_ |= OK;
}
cb = completedCallback_;
- monitor_.NotifyAll();
- }
- finally
- {
- monitor_.Unlock();
+ System.Threading.Monitor.PulseAll(monitor_);
}
}
catch(Ice.LocalException ex)
@@ -1239,8 +1159,7 @@ namespace IceInternal
if(proxy_.ice_isTwoway() || !sent)
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
if((state_ & Done) == 0)
{
@@ -1252,10 +1171,6 @@ namespace IceInternal
}
}
}
- finally
- {
- monitor_.Unlock();
- }
}
break;
}
@@ -1405,8 +1320,7 @@ namespace IceInternal
new public Ice.AsyncResult<T> whenCompleted(Ice.ExceptionCallback excb)
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
if(excb == null)
{
@@ -1423,10 +1337,6 @@ namespace IceInternal
return this;
}
}
- finally
- {
- monitor_.Unlock();
- }
instance_.clientThreadPool().dispatch(
@@ -1446,8 +1356,7 @@ namespace IceInternal
virtual public Ice.AsyncResult<T> whenCompleted(T cb, Ice.ExceptionCallback excb)
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
if(cb == null && excb == null)
{
@@ -1465,10 +1374,6 @@ namespace IceInternal
return this;
}
}
- finally
- {
- monitor_.Unlock();
- }
instance_.clientThreadPool().dispatch(() =>
{
@@ -1573,8 +1478,7 @@ namespace IceInternal
virtual public Ice.AsyncCallback sent__()
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
Debug.Assert((state_ & (Done | OK | Sent)) == 0);
state_ |= (Done | OK | Sent);
@@ -1589,17 +1493,13 @@ namespace IceInternal
instance_.timer().cancel(this);
timeoutRequestHandler_ = null;
}
- monitor_.NotifyAll();
+ System.Threading.Monitor.PulseAll(monitor_);
if(waitHandle_ != null)
{
waitHandle_.Set();
}
return sentCallback_;
}
- finally
- {
- monitor_.Unlock();
- }
}
public new void invokeSent__(Ice.AsyncCallback cb)
@@ -1609,8 +1509,7 @@ namespace IceInternal
virtual public void finished__(Ice.Exception exc)
{
- monitor_.Lock();
- try
+ lock(this)
{
if(childObserver_ != null)
{
@@ -1624,10 +1523,6 @@ namespace IceInternal
timeoutRequestHandler_ = null;
}
}
- finally
- {
- monitor_.Unlock();
- }
invokeException__(exc);
}
@@ -1678,8 +1573,7 @@ namespace IceInternal
}
else
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
if((state_ & Done) == 0)
{
@@ -1691,10 +1585,6 @@ namespace IceInternal
}
}
}
- finally
- {
- monitor_.Unlock();
- }
}
}
catch(RetryException)
@@ -1778,15 +1668,10 @@ namespace IceInternal
public void flushConnection(Ice.ConnectionI con)
{
- monitor_.Lock();
- try
+ lock(monitor_)
{
++_useCount;
}
- finally
- {
- monitor_.Unlock();
- }
try
@@ -1813,8 +1698,7 @@ namespace IceInternal
private void check(bool userThread)
{
Ice.AsyncCallback sentCallback = null;
- monitor_.Lock();
- try
+ lock(monitor_)
{
Debug.Assert(_useCount > 0);
if(--_useCount > 0)
@@ -1825,16 +1709,12 @@ namespace IceInternal
state_ |= (Done | OK | Sent);
os_.resize(0, false); // Clear buffer now, instead of waiting for AsyncResult deallocation
sentCallback = sentCallback_;
- monitor_.NotifyAll();
+ System.Threading.Monitor.PulseAll(monitor_);
if(waitHandle_ != null)
{
waitHandle_.Set();
}
}
- finally
- {
- monitor_.Unlock();
- }
//
// sentSynchronously_ is immutable here.
diff --git a/cs/src/Ice/TcpTransceiver.cs b/cs/src/Ice/TcpTransceiver.cs
index 61382c08584..fa45847e38b 100644
--- a/cs/src/Ice/TcpTransceiver.cs
+++ b/cs/src/Ice/TcpTransceiver.cs
@@ -11,9 +11,9 @@
// .NET and Silverlight use the new socket asynchronous APIs whereas
// the compact framework and mono still use the old Begin/End APIs.
//
-#if !COMPACT && !__MonoCS__ && !UNITY
-#define ICE_SOCKET_ASYNC_API
-#endif
+// #if !COMPACT && !__MonoCS__ && !UNITY
+// #define ICE_SOCKET_ASYNC_API
+// #endif
namespace IceInternal
{
@@ -146,7 +146,17 @@ namespace IceInternal
public int write(Buffer buf)
{
-#if COMPACT || SILVERLIGHT
+ int packetSize = buf.b.remaining();
+ if(packetSize == 0)
+ {
+ return SocketOperation.None;
+ }
+
+#if COMPACT || SILVERLIGHT || true
+ if(_writeResult != null)
+ {
+ return SocketOperation.None;
+ }
//
// Silverlight and the Compact .NET Frameworks don't support the use of synchronous socket
// operations on a non-blocking socket. Returning SocketOperation.Write here forces the caller
@@ -223,6 +233,12 @@ namespace IceInternal
public int read(Buffer buf, ref bool hasMoreData)
{
+ int remaining = buf.b.remaining();
+ if(remaining == 0)
+ {
+ return SocketOperation.None;
+ }
+
#if COMPACT || SILVERLIGHT
//
// Silverlight and the Compact .NET Framework don't support the use of synchronous socket
@@ -230,13 +246,7 @@ namespace IceInternal
//
return SocketOperation.Read;
#else
- int remaining = buf.b.remaining();
int position = buf.b.position();
- if(remaining == 0)
- {
- return SocketOperation.None;
- }
-
while(buf.b.hasRemaining())
{
try
diff --git a/cs/src/Ice/ThreadPool.cs b/cs/src/Ice/ThreadPool.cs
index 5373d126d9d..53a44bba830 100644
--- a/cs/src/Ice/ThreadPool.cs
+++ b/cs/src/Ice/ThreadPool.cs
@@ -20,7 +20,7 @@ namespace IceInternal
internal struct ThreadPoolMessage
{
- public ThreadPoolMessage(IceUtilInternal.Monitor mutex)
+ public ThreadPoolMessage(object mutex)
{
_mutex = mutex;
_finish = false;
@@ -67,20 +67,15 @@ namespace IceInternal
// of the event handler. We need to lock the event handler here to call
// finishMessage.
//
- _mutex.Lock();
- try
+ lock(_mutex)
{
current.finishMessage(false);
Debug.Assert(!current.completedSynchronously);
}
- finally
- {
- _mutex.Unlock();
- }
}
}
- private IceUtilInternal.Monitor _mutex;
+ private object _mutex;
private bool _finish;
private bool _finishWithIO;
}
@@ -253,33 +248,23 @@ namespace IceInternal
public void destroy()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_destroyed);
_destroyed = true;
- _m.NotifyAll();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.PulseAll(this);
}
}
public void updateObservers()
{
- _m.Lock();
- try
+ lock(this)
{
foreach(WorkerThread t in _threads)
{
t.updateObserver();
}
}
- finally
- {
- _m.Unlock();
- }
}
public void initialize(EventHandler handler)
@@ -294,8 +279,7 @@ namespace IceInternal
public void update(EventHandler handler, int remove, int add)
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_destroyed);
@@ -316,24 +300,20 @@ namespace IceInternal
if((add & SocketOperation.Read) != 0 && (handler._pending & SocketOperation.Read) == 0)
{
handler._pending |= SocketOperation.Read;
- executeNonBlocking(delegate()
- {
- messageCallback(new ThreadPoolCurrent(this, handler, SocketOperation.Read));
- });
+ executeNonBlocking(() =>
+ {
+ messageCallback(new ThreadPoolCurrent(this, handler, SocketOperation.Read));
+ });
}
else if((add & SocketOperation.Write) != 0 && (handler._pending & SocketOperation.Write) == 0)
{
handler._pending |= SocketOperation.Write;
- executeNonBlocking(delegate()
- {
- messageCallback(new ThreadPoolCurrent(this, handler, SocketOperation.Write));
- });
+ executeNonBlocking(() =>
+ {
+ messageCallback(new ThreadPoolCurrent(this, handler, SocketOperation.Write));
+ });
}
}
- finally
- {
- _m.Unlock();
- }
}
public void unregister(EventHandler handler, int op)
@@ -343,8 +323,7 @@ namespace IceInternal
public void finish(EventHandler handler)
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_destroyed);
@@ -354,22 +333,18 @@ namespace IceInternal
if(handler._pending == 0)
{
handler._registered = SocketOperation.None;
- executeNonBlocking(delegate()
- {
- ThreadPoolCurrent current =
- new ThreadPoolCurrent(this, handler, SocketOperation.None);
- handler.finished(ref current);
- });
+ executeNonBlocking(() =>
+ {
+ ThreadPoolCurrent current =
+ new ThreadPoolCurrent(this, handler, SocketOperation.None);
+ handler.finished(ref current);
+ });
}
else
{
handler._finish = true;
}
}
- finally
- {
- _m.Unlock();
- }
}
#if COMPACT
@@ -405,13 +380,12 @@ namespace IceInternal
public void dispatch(System.Action call, Ice.Connection con)
#endif
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_destroyed);
if(_workItems.Count == 0)
{
- _m.Notify();
+ System.Threading.Monitor.Pulse(this);
}
_workItems.Enqueue(() =>
@@ -458,24 +432,15 @@ namespace IceInternal
}
}
}
- finally
- {
- _m.Unlock();
- }
}
public void executeNonBlocking(ThreadPoolWorkItem workItem)
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_destroyed);
_instance.asyncIOThread().queue(workItem);
}
- finally
- {
- _m.Unlock();
- }
}
public void joinWithAllThreads()
@@ -508,8 +473,7 @@ namespace IceInternal
ThreadPoolWorkItem workItem = null;
while(true)
{
- _m.Lock();
- try
+ lock(this)
{
if(workItem != null)
{
@@ -532,7 +496,7 @@ namespace IceInternal
if(_threadIdleTime > 0)
{
- if(!_m.TimedWait(_threadIdleTime * 1000) && _workItems.Count == 0) // If timeout
+ if(!System.Threading.Monitor.Wait(this, _threadIdleTime * 1000) && _workItems.Count == 0) // If timeout
{
if(_destroyed)
{
@@ -555,29 +519,29 @@ namespace IceInternal
}
_threads.Remove(thread);
- _instance.asyncIOThread().queue(delegate()
- {
- thread.join();
- });
+ _instance.asyncIOThread().queue(() =>
+ {
+ thread.join();
+ });
return;
}
else
{
Debug.Assert(_serverIdleTime > 0 && _inUse == 0 && _threads.Count == 1);
- if(!_m.TimedWait(_serverIdleTime * 1000) && _workItems.Count == 0)
+ if(!System.Threading.Monitor.Wait(this, _serverIdleTime * 1000) && _workItems.Count == 0)
{
if(!_destroyed)
{
- _workItems.Enqueue(delegate()
- {
- try
- {
- _instance.objectAdapterFactory().shutdown();
- }
- catch(Ice.CommunicatorDestroyedException)
- {
- }
- });
+ _workItems.Enqueue(() =>
+ {
+ try
+ {
+ _instance.objectAdapterFactory().shutdown();
+ }
+ catch(Ice.CommunicatorDestroyedException)
+ {
+ }
+ });
}
}
}
@@ -585,7 +549,7 @@ namespace IceInternal
}
else
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
}
@@ -604,10 +568,6 @@ namespace IceInternal
_instance.initializationData().logger.warning(s);
}
}
- finally
- {
- _m.Unlock();
- }
try
{
@@ -701,10 +661,10 @@ namespace IceInternal
else
{
ThreadPoolCurrent c = current;
- executeNonBlocking(delegate()
- {
- messageCallback(c);
- });
+ executeNonBlocking(() =>
+ {
+ messageCallback(c);
+ });
}
}
else
@@ -906,8 +866,6 @@ namespace IceInternal
private int _inUse; // Number of threads that are currently in use.
private Queue<ThreadPoolWorkItem> _workItems;
-
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
}
diff --git a/cs/src/Ice/Timer.cs b/cs/src/Ice/Timer.cs
index 01fa72245f1..506a84ed96b 100644
--- a/cs/src/Ice/Timer.cs
+++ b/cs/src/Ice/Timer.cs
@@ -30,8 +30,7 @@ namespace IceInternal
{
public void destroy()
{
- _m.Lock();
- try
+ lock(this)
{
if(_instance == null)
{
@@ -39,23 +38,18 @@ namespace IceInternal
}
_instance = null;
- _m.Notify();
+ System.Threading.Monitor.Pulse(this);
_tokens.Clear();
_tasks.Clear();
}
- finally
- {
- _m.Unlock();
- }
_thread.Join();
}
public void schedule(TimerTask task, long delay)
{
- _m.Lock();
- try
+ lock(this)
{
if(_instance == null)
{
@@ -85,19 +79,14 @@ namespace IceInternal
if(token.scheduledTime < _wakeUpTime)
{
- _m.Notify();
+ System.Threading.Monitor.Pulse(this);
}
}
- finally
- {
- _m.Unlock();
- }
}
public void scheduleRepeated(TimerTask task, long period)
{
- _m.Lock();
- try
+ lock(this)
{
if(_instance == null)
{
@@ -127,19 +116,14 @@ namespace IceInternal
if(token.scheduledTime < _wakeUpTime)
{
- _m.Notify();
+ System.Threading.Monitor.Pulse(this);
}
}
- finally
- {
- _m.Unlock();
- }
}
public bool cancel(TimerTask task)
{
- _m.Lock();
- try
+ lock(this)
{
if(_instance == null)
{
@@ -155,10 +139,6 @@ namespace IceInternal
_tokens.Remove(token);
return true;
}
- finally
- {
- _m.Unlock();
- }
}
//
@@ -211,8 +191,7 @@ namespace IceInternal
Token token = null;
while(true)
{
- _m.Lock();
- try
+ lock(this)
{
if(_instance != null)
{
@@ -248,7 +227,7 @@ namespace IceInternal
if(_tokens.Count == 0)
{
_wakeUpTime = System.Int64.MaxValue;
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
if(_instance == null)
@@ -284,7 +263,7 @@ namespace IceInternal
}
_wakeUpTime = first.scheduledTime;
- _m.TimedWait((int)(first.scheduledTime - now));
+ System.Threading.Monitor.Wait(this, (int)(first.scheduledTime - now));
}
if(_instance == null)
@@ -292,10 +271,6 @@ namespace IceInternal
break;
}
}
- finally
- {
- _m.Unlock();
- }
if(token != null)
{
@@ -305,8 +280,7 @@ namespace IceInternal
}
catch(System.Exception ex)
{
- _m.Lock();
- try
+ lock(this)
{
if(_instance != null)
{
@@ -314,10 +288,6 @@ namespace IceInternal
_instance.initializationData().logger.error(s);
}
}
- finally
- {
- _m.Unlock();
- }
}
}
}
@@ -397,8 +367,6 @@ namespace IceInternal
private long _wakeUpTime = System.Int64.MaxValue;
private int _tokenId = 0;
private Thread _thread;
-
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
}
diff --git a/cs/src/Ice/UdpTransceiver.cs b/cs/src/Ice/UdpTransceiver.cs
index ee15d11d19f..a2ed32f1f1b 100644
--- a/cs/src/Ice/UdpTransceiver.cs
+++ b/cs/src/Ice/UdpTransceiver.cs
@@ -134,7 +134,15 @@ namespace IceInternal
public int write(Buffer buf)
{
+ if(!buf.b.hasRemaining())
+ {
+ return SocketOperation.None;
+ }
#if COMPACT || SILVERLIGHT
+ if(_writeResult != null)
+ {
+ return SocketOperation.None;
+ }
//
// Silverlight and the Compact .NET Framework don't support the use of synchronous socket
// operations on a non-blocking socket. Returning SocketOperation.Write here forces the
@@ -142,11 +150,6 @@ namespace IceInternal
//
return SocketOperation.Write;
#else
- if(!buf.b.hasRemaining())
- {
- return SocketOperation.None;
- }
-
Debug.Assert(buf.b.position() == 0);
Debug.Assert(_fd != null && _state >= StateConnected);
@@ -214,6 +217,10 @@ namespace IceInternal
public int read(Buffer buf, ref bool hasMoreData)
{
+ if(!buf.b.hasRemaining())
+ {
+ return SocketOperation.None;
+ }
#if COMPACT || SILVERLIGHT
//
// Silverlight and the Compact .NET Framework don't support the use of synchronous socket
@@ -222,11 +229,6 @@ namespace IceInternal
//
return SocketOperation.Read;
#else
- if(!buf.b.hasRemaining())
- {
- return SocketOperation.None;
- }
-
Debug.Assert(buf.b.position() == 0);
Debug.Assert(_fd != null);
diff --git a/cs/src/IceBox/ServiceManagerI.cs b/cs/src/IceBox/ServiceManagerI.cs
index 1d32474bd45..fa6e08c523a 100644
--- a/cs/src/IceBox/ServiceManagerI.cs
+++ b/cs/src/IceBox/ServiceManagerI.cs
@@ -38,8 +38,7 @@ class ServiceManagerI : ServiceManagerDisp_
public override void startService(string name, Ice.Current current)
{
ServiceInfo info = new ServiceInfo();
- _m.Lock();
- try
+ lock(this)
{
//
// Search would be more efficient if services were contained in
@@ -66,10 +65,6 @@ class ServiceManagerI : ServiceManagerDisp_
}
_pendingStatusChanges = true;
}
- finally
- {
- _m.Unlock();
- }
bool started = false;
try
@@ -83,8 +78,7 @@ class ServiceManagerI : ServiceManagerDisp_
_logger.warning("ServiceManager: exception while starting service " + info.name + ":\n" + e.ToString());
}
- _m.Lock();
- try
+ lock(this)
{
int i;
for(i = 0; i < _services.Count; ++i)
@@ -109,19 +103,14 @@ class ServiceManagerI : ServiceManagerDisp_
}
}
_pendingStatusChanges = false;
- _m.NotifyAll();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.PulseAll(this);
}
}
public override void stopService(string name, Ice.Current current)
{
ServiceInfo info = new ServiceInfo();
- _m.Lock();
- try
+ lock(this)
{
//
// Search would be more efficient if services were contained in
@@ -148,10 +137,6 @@ class ServiceManagerI : ServiceManagerDisp_
}
_pendingStatusChanges = true;
}
- finally
- {
- _m.Unlock();
- }
bool stopped = false;
try
@@ -164,8 +149,7 @@ class ServiceManagerI : ServiceManagerDisp_
_logger.warning("ServiceManager: exception while stopping service " + info.name + "\n" + e.ToString());
}
- _m.Lock();
- try
+ lock(this)
{
int i;
for(i = 0; i < _services.Count; ++i)
@@ -190,11 +174,7 @@ class ServiceManagerI : ServiceManagerDisp_
}
}
_pendingStatusChanges = false;
- _m.NotifyAll();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.PulseAll(this);
}
}
@@ -206,8 +186,7 @@ class ServiceManagerI : ServiceManagerDisp_
// Null observers and duplicate registrations are ignored
//
- _m.Lock();
- try
+ lock(this)
{
if(observer != null)
{
@@ -235,10 +214,6 @@ class ServiceManagerI : ServiceManagerDisp_
}
}
}
- finally
- {
- _m.Unlock();
- }
if(activeServices.Count > 0)
{
@@ -471,8 +446,7 @@ class ServiceManagerI : ServiceManagerDisp_
private void startService(string service, string entryPoint, string[] args)
{
- _m.Lock();
- try
+ lock(this)
{
//
// Extract the assembly name and the class name.
@@ -788,23 +762,18 @@ class ServiceManagerI : ServiceManagerDisp_
}
}
- finally
- {
- _m.Unlock();
- }
}
private void stopAll()
{
- _m.Lock();
- try
+ lock(this)
{
//
// First wait for any active startService/stopService calls to complete.
//
while(_pendingStatusChanges)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
//
@@ -860,10 +829,6 @@ class ServiceManagerI : ServiceManagerDisp_
_services.Clear();
servicesStopped(stoppedServices, _observers.Keys);
}
- finally
- {
- _m.Unlock();
- }
}
private void servicesStarted(List<String> services, Dictionary<ServiceObserverPrx, bool>.KeyCollection observers)
@@ -909,8 +874,7 @@ class ServiceManagerI : ServiceManagerDisp_
}
catch(Ice.LocalException ex)
{
- _m.Lock();
- try
+ lock(this)
{
ServiceObserverPrx observer = ServiceObserverPrxHelper.uncheckedCast(result.getProxy());
if(_observers.Remove(observer))
@@ -918,10 +882,6 @@ class ServiceManagerI : ServiceManagerDisp_
observerRemoved(observer, ex);
}
}
- finally
- {
- _m.Unlock();
- }
}
}
@@ -1082,7 +1042,6 @@ class ServiceManagerI : ServiceManagerDisp_
private bool _pendingStatusChanges = false;
private Dictionary<ServiceObserverPrx, bool> _observers = new Dictionary<ServiceObserverPrx, bool>();
private int _traceServiceObserver = 0;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
}
diff --git a/cs/src/Makefile.mak b/cs/src/Makefile.mak
index 229c4aa9567..b9d96fe1fe1 100644
--- a/cs/src/Makefile.mak
+++ b/cs/src/Makefile.mak
@@ -11,10 +11,9 @@ top_srcdir = ..
!include $(top_srcdir)\config\Make.rules.mak.cs
-SUBDIRS = Ice IceStorm Glacier2 IcePatch2 IceGrid IceDiscovery IceWS
-
+SUBDIRS = Ice IceStorm Glacier2 IcePatch2 IceGrid
!if "$(COMPACT)" != "yes" && "$(SILVERLIGHT)" != "yes"
-SUBDIRS = $(SUBDIRS) IceSSL
+SUBDIRS = $(SUBDIRS) IceSSL IceDiscovery IceWS
!endif
!if "$(SILVERLIGHT)" != "yes"
diff --git a/cs/test/Glacier2/router/CallbackI.cs b/cs/test/Glacier2/router/CallbackI.cs
index 34cc376d759..e312a978896 100644
--- a/cs/test/Glacier2/router/CallbackI.cs
+++ b/cs/test/Glacier2/router/CallbackI.cs
@@ -45,16 +45,11 @@ public sealed class CallbackReceiverI : CallbackReceiverDisp_
public override void
callback(Ice.Current current)
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_callback);
_callback = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
@@ -71,22 +66,16 @@ public sealed class CallbackReceiverI : CallbackReceiverDisp_
public void
callbackOK()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_callback)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_callback = false;
}
- finally
- {
- _m.Unlock();
- }
}
private bool _callback;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
diff --git a/cs/test/Glacier2/sessionHelper/Client.cs b/cs/test/Glacier2/sessionHelper/Client.cs
index 45dd2971664..70d1c395400 100644
--- a/cs/test/Glacier2/sessionHelper/Client.cs
+++ b/cs/test/Glacier2/sessionHelper/Client.cs
@@ -66,15 +66,10 @@ public class Client
catch(Glacier2.PermissionDeniedException)
{
Console.Out.WriteLine("ok");
- me.lck.Lock();
- try
+ lock(me)
{
wakeUp();
}
- finally
- {
- me.lck.Unlock();
- }
}
catch(System.Exception)
{
@@ -95,30 +90,20 @@ public class Client
connected(Glacier2.SessionHelper session)
{
Console.Out.WriteLine("ok");
- me.lck.Lock();
- try
+ lock(me)
{
wakeUp();
}
- finally
- {
- me.lck.Unlock();
- }
}
public void
disconnected(Glacier2.SessionHelper session)
{
Console.Out.WriteLine("ok");
- me.lck.Lock();
- try
+ lock(me)
{
wakeUp();
}
- finally
- {
- me.lck.Unlock();
- }
}
public void
@@ -159,15 +144,10 @@ public class Client
catch(Ice.ConnectionRefusedException)
{
Console.Out.WriteLine("ok");
- me.lck.Lock();
- try
+ lock(me)
{
wakeUp();
}
- finally
- {
- me.lck.Unlock();
- }
}
catch(System.Exception)
{
@@ -194,8 +174,7 @@ public class Client
//
// Test to create a session with wrong userid/password
//
- lck.Lock();
- try
+ lock(this)
{
Console.Out.Write("testing SessionHelper connect with wrong userid/password... ");
Console.Out.Flush();
@@ -208,12 +187,12 @@ public class Client
while(true)
{
#if COMPACT
- lck.Wait();
+ System.Threading.Monitor.Wait(this);
break;
#else
try
{
- lck.Wait();
+ System.Threading.Monitor.Wait(this);
break;
}
catch(ThreadInterruptedException)
@@ -222,14 +201,9 @@ public class Client
#endif
}
}
- finally
- {
- lck.Unlock();
- }
_factory = new Glacier2.SessionFactoryHelper(_initData, new SessionCalback2());
- lck.Lock();
- try
+ lock(this)
{
Console.Out.Write("testing SessionHelper connect... ");
Console.Out.Flush();
@@ -241,12 +215,12 @@ public class Client
while(true)
{
#if COMPACT
- lck.Wait();
+ System.Threading.Monitor.Wait(this);
break;
#else
try
{
- lck.Wait();
+ System.Threading.Monitor.Wait(this);
break;
}
catch(ThreadInterruptedException)
@@ -309,12 +283,12 @@ public class Client
while(true)
{
#if COMPACT
- lck.Wait();
+ System.Threading.Monitor.Wait(this);
break;
#else
try
{
- lck.Wait();
+ System.Threading.Monitor.Wait(this);
break;
}
catch(ThreadInterruptedException)
@@ -390,14 +364,9 @@ public class Client
Console.Out.WriteLine("ok");
}
}
- finally
- {
- lck.Unlock();
- }
_factory = new Glacier2.SessionFactoryHelper(_initData, new SessionCalback3());
- lck.Lock();
- try
+ lock(this)
{
Console.Out.Write("testing SessionHelper connect after router shutdown... ");
Console.Out.Flush();
@@ -410,12 +379,12 @@ public class Client
while(true)
{
#if COMPACT
- lck.Wait();
+ System.Threading.Monitor.Wait(this);
break;
#else
try
{
- lck.Wait();
+ System.Threading.Monitor.Wait(this);
break;
}
catch(ThreadInterruptedException)
@@ -439,10 +408,6 @@ public class Client
_session.destroy();
Console.Out.WriteLine("ok");
}
- finally
- {
- lck.Unlock();
- }
return 0;
}
@@ -450,7 +415,7 @@ public class Client
public static void
wakeUp()
{
- me.lck.Notify();
+ System.Threading.Monitor.Pulse(me);
}
private static void
@@ -463,7 +428,6 @@ public class Client
}
public static App me;
- public IceUtilInternal.Monitor lck = new IceUtilInternal.Monitor();
private Ice.InitializationData _initData;
private Glacier2.SessionHelper _session;
private Glacier2.SessionFactoryHelper _factory;
diff --git a/cs/test/Ice/admin/TestI.cs b/cs/test/Ice/admin/TestI.cs
index 15d214ecc8b..d8bdbc9d381 100644
--- a/cs/test/Ice/admin/TestI.cs
+++ b/cs/test/Ice/admin/TestI.cs
@@ -34,8 +34,7 @@ public class RemoteCommunicatorI : RemoteCommunicatorDisp_, Ice.PropertiesAdminU
override public Dictionary<string, string> getChanges(Ice.Current current)
{
- _m.Lock();
- try
+ lock(this)
{
//
// The client calls PropertiesAdmin::setProperties() and then invokes
@@ -46,17 +45,13 @@ public class RemoteCommunicatorI : RemoteCommunicatorDisp_, Ice.PropertiesAdminU
//
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_called = false;
return _changes;
}
- finally
- {
- _m.Unlock();
- }
}
override public void shutdown(Ice.Current current)
@@ -80,23 +75,17 @@ public class RemoteCommunicatorI : RemoteCommunicatorDisp_, Ice.PropertiesAdminU
public void updated(Dictionary<string, string> changes)
{
- _m.Lock();
- try
+ lock(this)
{
_changes = changes;
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private Ice.Communicator _communicator;
private Dictionary<string, string> _changes;
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
public class RemoteCommunicatorFactoryI : RemoteCommunicatorFactoryDisp_
diff --git a/cs/test/Ice/ami/AllTests.cs b/cs/test/Ice/ami/AllTests.cs
index e38f7f77f66..1394001697a 100644
--- a/cs/test/Ice/ami/AllTests.cs
+++ b/cs/test/Ice/ami/AllTests.cs
@@ -47,38 +47,27 @@ public class AllTests : TestCommon.TestApp
public virtual void check()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_called = false;
}
- finally
- {
- _m.Unlock();
- }
}
public virtual void called()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_called);
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
private class AsyncCallback : CallbackBase
diff --git a/cs/test/Ice/ami/Collocated.cs b/cs/test/Ice/ami/Collocated.cs
index 97d77c20bd3..0a0190e70a2 100644
--- a/cs/test/Ice/ami/Collocated.cs
+++ b/cs/test/Ice/ami/Collocated.cs
@@ -52,7 +52,7 @@ public class Collocated
// When using Ice for .NET Compact Framework, we need to specify
// the assembly so that Ice can locate classes and exceptions.
//
- initData.properties.setProperty("Ice.FactoryAssemblies", "client");
+ initData.properties.setProperty("Ice.FactoryAssemblies", "collocated");
#endif
communicator = Ice.Util.initialize(ref args, initData);
status = run(args, communicator);
diff --git a/cs/test/Ice/ami/TestI.cs b/cs/test/Ice/ami/TestI.cs
index 56894e07a0f..f1f482eee84 100644
--- a/cs/test/Ice/ami/TestI.cs
+++ b/cs/test/Ice/ami/TestI.cs
@@ -41,50 +41,35 @@ public class TestI : TestIntfDisp_
override public void
opBatch(Ice.Current current)
{
- _m.Lock();
- try
+ lock(this)
{
++_batchCount;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
override public int
opBatchCount(Ice.Current current)
{
- _m.Lock();
- try
+ lock(this)
{
return _batchCount;
}
- finally
- {
- _m.Unlock();
- }
}
override public bool
waitForBatch(int count, Ice.Current current)
{
- _m.Lock();
- try
+ lock(this)
{
while(_batchCount < count)
{
- _m.TimedWait(5000);
+ System.Threading.Monitor.Wait(this, 5000);
}
bool result = count == _batchCount;
_batchCount = 0;
return result;
}
- finally
- {
- _m.Unlock();
- }
}
override public void
@@ -100,7 +85,6 @@ public class TestI : TestIntfDisp_
}
private int _batchCount;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
public class TestControllerI : TestIntfControllerDisp_
diff --git a/cs/test/Ice/background/AllTests.cs b/cs/test/Ice/background/AllTests.cs
index 69d0981ad9c..ab389d8549c 100644
--- a/cs/test/Ice/background/AllTests.cs
+++ b/cs/test/Ice/background/AllTests.cs
@@ -31,52 +31,36 @@ public class AllTests
public virtual void check()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_called = false;
}
- finally
- {
- _m.Unlock();
- }
}
public virtual void called()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_called);
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
public virtual bool isCalled()
{
- _m.Lock();
- try
+ lock(this)
{
return _called;
}
- finally
- {
- _m.Unlock();
- }
}
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
private class OpAMICallback
diff --git a/cs/test/Ice/background/BackgroundControllerI.cs b/cs/test/Ice/background/BackgroundControllerI.cs
index dd66e6aa932..52b346aec7b 100644
--- a/cs/test/Ice/background/BackgroundControllerI.cs
+++ b/cs/test/Ice/background/BackgroundControllerI.cs
@@ -15,46 +15,31 @@ internal class BackgroundControllerI : BackgroundControllerDisp_
{
public override void pauseCall(string opName, Ice.Current current)
{
- _m.Lock();
- try
+ lock(this)
{
_pausedCalls.Add(opName);
}
- finally
- {
- _m.Unlock();
- }
}
public override void resumeCall(string opName, Ice.Current current)
{
- _m.Lock();
- try
+ lock(this)
{
_pausedCalls.Remove(opName);
- _m.NotifyAll();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.PulseAll(this);
}
}
internal void checkCallPause(Ice.Current current)
{
- _m.Lock();
- try
+ lock(this)
{
while(_pausedCalls.Contains(current.operation))
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
break;
}
}
- finally
- {
- _m.Unlock();
- }
}
public override void holdAdapter(Ice.Current current)
@@ -110,5 +95,4 @@ internal class BackgroundControllerI : BackgroundControllerDisp_
private HashSet<string> _pausedCalls = new HashSet<string>();
#endif
private Configuration _configuration;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
diff --git a/cs/test/Ice/binding/AllTests.cs b/cs/test/Ice/binding/AllTests.cs
index 89df931475d..995d3be4994 100644
--- a/cs/test/Ice/binding/AllTests.cs
+++ b/cs/test/Ice/binding/AllTests.cs
@@ -30,39 +30,29 @@ public class AllTests : TestCommon.TestApp
{
private static string getAdapterNameWithAMI(TestIntfPrx testIntf)
{
- IceUtilInternal.Monitor m = new IceUtilInternal.Monitor();
+ object m = new object();
string result = null;
testIntf.begin_getAdapterName().whenCompleted(
(string name) =>
{
- m.Lock();
- try
+ lock(m)
{
result = name;
- m.Notify();
- }
- finally
- {
- m.Unlock();
+ System.Threading.Monitor.Pulse(m);
}
},
(Ice.Exception ex) =>
{
test(false);
});
- m.Lock();
- try
+ lock(m)
{
while(result == null)
{
- m.Wait();
+ System.Threading.Monitor.Wait(m);
}
return result;
}
- finally
- {
- m.Unlock();
- }
}
private static void shuffle(ref List<RemoteObjectAdapterPrx> array)
diff --git a/cs/test/Ice/dictMapping/TwowaysAMI.cs b/cs/test/Ice/dictMapping/TwowaysAMI.cs
index 14ee93c2870..412650eff0b 100644
--- a/cs/test/Ice/dictMapping/TwowaysAMI.cs
+++ b/cs/test/Ice/dictMapping/TwowaysAMI.cs
@@ -32,39 +32,28 @@ public class TwowaysAMI
public virtual void check()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_called = false;
}
- finally
- {
- _m.Unlock();
- }
}
public virtual void called()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_called);
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
private class AMI_MyClass_opNVI : Test.AMI_MyClass_opNV
diff --git a/cs/test/Ice/dictMapping/TwowaysNewAMI.cs b/cs/test/Ice/dictMapping/TwowaysNewAMI.cs
index 7ad80688bf6..820b24c0904 100644
--- a/cs/test/Ice/dictMapping/TwowaysNewAMI.cs
+++ b/cs/test/Ice/dictMapping/TwowaysNewAMI.cs
@@ -32,39 +32,28 @@ public class TwowaysNewAMI
public virtual void check()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_called = false;
}
- finally
- {
- _m.Unlock();
- }
}
public virtual void called()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_called);
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
private class Callback
diff --git a/cs/test/Ice/dispatcher/AllTests.cs b/cs/test/Ice/dispatcher/AllTests.cs
index a5cfe2f1b1d..f66b541e3d9 100644
--- a/cs/test/Ice/dispatcher/AllTests.cs
+++ b/cs/test/Ice/dispatcher/AllTests.cs
@@ -7,6 +7,7 @@
//
// **********************************************************************
+
using System;
using System.Collections;
using System.Collections.Generic;
@@ -37,19 +38,14 @@ public class AllTests : TestCommon.TestApp
public void check()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_called = false;
}
- finally
- {
- _m.Unlock();
- }
}
public void response()
@@ -83,21 +79,15 @@ public class AllTests : TestCommon.TestApp
public void called()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_called);
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
#if SILVERLIGHT
diff --git a/cs/test/Ice/dispatcher/Dispatcher.cs b/cs/test/Ice/dispatcher/Dispatcher.cs
index 736794adf10..f56b90ccb12 100644
--- a/cs/test/Ice/dispatcher/Dispatcher.cs
+++ b/cs/test/Ice/dispatcher/Dispatcher.cs
@@ -40,12 +40,11 @@ public class Dispatcher
#else
System.Action call = null;
#endif
- _m.Lock();
- try
+ lock(_m)
{
if(!_terminated && _calls.Count == 0)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(_m);
}
if(_calls.Count > 0)
@@ -58,10 +57,6 @@ public class Dispatcher
return;
}
}
- finally
- {
- _m.Unlock();
- }
if(call != null)
{
@@ -84,32 +79,22 @@ public class Dispatcher
public void dispatch(System.Action call, Ice.Connection con)
#endif
{
- _m.Lock();
- try
+ lock(_m)
{
_calls.Enqueue(call);
if(_calls.Count == 1)
{
- _m.Notify();
+ System.Threading.Monitor.Pulse(_m);
}
}
- finally
- {
- _m.Unlock();
- }
}
static public void terminate()
{
- _m.Lock();
- try
+ lock(_m)
{
_instance._terminated = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(_m);
}
_instance._thread.Join();
@@ -129,5 +114,5 @@ public class Dispatcher
#endif
Thread _thread;
bool _terminated = false;
- private static readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
+ private static readonly object _m = new object();
}
diff --git a/cs/test/Ice/exceptions/AllTests.cs b/cs/test/Ice/exceptions/AllTests.cs
index 5748f5542e9..e5d1272cc2b 100644
--- a/cs/test/Ice/exceptions/AllTests.cs
+++ b/cs/test/Ice/exceptions/AllTests.cs
@@ -35,39 +35,28 @@ public class AllTests : TestCommon.TestApp
public virtual void check()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_called = false;
}
- finally
- {
- _m.Unlock();
- }
}
public virtual void called()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_called);
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
private class AMI_Thrower_throwAasAI : AMI_Thrower_throwAasA
diff --git a/cs/test/Ice/exceptions/Collocated.cs b/cs/test/Ice/exceptions/Collocated.cs
index a362d426fe5..46482a3c90e 100644
--- a/cs/test/Ice/exceptions/Collocated.cs
+++ b/cs/test/Ice/exceptions/Collocated.cs
@@ -38,6 +38,14 @@ public class Collocated
{
Ice.InitializationData initData = new Ice.InitializationData();
initData.properties = Ice.Util.createProperties();
+#if COMPACT
+ //
+ // When using Ice for .NET Compact Framework, we need to specify
+ // the assembly so that Ice can locate classes and exceptions.
+ //
+ initData.properties.setProperty("Ice.FactoryAssemblies", "collocated");
+#endif
+
initData.properties.setProperty("Ice.Warn.Dispatch", "0");
initData.properties.setProperty("Ice.MessageSizeMax", "10"); // 10KB max
communicator = Ice.Util.initialize(ref args, initData);
diff --git a/cs/test/Ice/faultTolerance/AllTests.cs b/cs/test/Ice/faultTolerance/AllTests.cs
index 2129e3bd619..3c1a2e1ad44 100644
--- a/cs/test/Ice/faultTolerance/AllTests.cs
+++ b/cs/test/Ice/faultTolerance/AllTests.cs
@@ -29,46 +29,35 @@ public class AllTests : TestCommon.TestApp
{
private class Callback
{
- public Callback()
+ internal Callback()
{
_called = false;
}
- public void check()
+ public virtual void check()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
-
+
_called = false;
}
- finally
- {
- _m.Unlock();
- }
}
-
- public void called()
+
+ public virtual void called()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_called);
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
private static void exceptAbortI(Ice.Exception ex) {
diff --git a/cs/test/Ice/hold/AllTests.cs b/cs/test/Ice/hold/AllTests.cs
index b53d29a4403..5f210443414 100644
--- a/cs/test/Ice/hold/AllTests.cs
+++ b/cs/test/Ice/hold/AllTests.cs
@@ -78,39 +78,28 @@ public class AllTests : TestCommon.TestApp
public void
sent(bool sync)
{
- _m.Lock();
- try
+ lock(this)
{
_sent = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
public void
waitForSent()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_sent)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
}
- finally
- {
- _m.Unlock();
- }
}
private bool _sent = false;
private Condition _condition;
private int _expected;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
#if SILVERLIGHT
diff --git a/cs/test/Ice/invoke/AllTests.cs b/cs/test/Ice/invoke/AllTests.cs
index 2a8a6f1426b..32a50eb0375 100644
--- a/cs/test/Ice/invoke/AllTests.cs
+++ b/cs/test/Ice/invoke/AllTests.cs
@@ -36,41 +36,30 @@ public class AllTests : TestCommon.TestApp
public virtual void check()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_called = false;
}
- finally
- {
- _m.Unlock();
- }
}
public virtual void called()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_called);
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
-
+
private class Callback
{
public Callback(Ice.Communicator communicator, bool useCookie)
diff --git a/cs/test/Ice/metrics/AllTests.cs b/cs/test/Ice/metrics/AllTests.cs
index a3bd5467385..20360056410 100644
--- a/cs/test/Ice/metrics/AllTests.cs
+++ b/cs/test/Ice/metrics/AllTests.cs
@@ -54,15 +54,10 @@ public class AllTests : TestCommon.TestApp
public void response()
{
- _m.Lock();
- try
+ lock(this)
{
_wait = false;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
@@ -73,23 +68,17 @@ public class AllTests : TestCommon.TestApp
public void waitForResponse()
{
- _m.Lock();
- try
+ lock(this)
{
while(_wait)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_wait = true;
}
- finally
- {
- _m.Unlock();
- }
}
private bool _wait;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
};
static private Dictionary<string, string>
@@ -143,18 +132,16 @@ public class AllTests : TestCommon.TestApp
{
_updated = false;
_serverProps = serverProps;
- _monitor = new IceUtilInternal.Monitor();
}
public void
waitForUpdate()
{
- _monitor.Lock();
- try
+ lock(this)
{
while(!_updated)
{
- _monitor.Wait();
+ System.Threading.Monitor.Wait(this);
}
// Ensure that the previous updates were committed, the setProperties call returns before
// notifying the callbacks so to ensure all the update callbacks have be notified we call
@@ -163,30 +150,20 @@ public class AllTests : TestCommon.TestApp
_serverProps.setProperties(new Dictionary<string, string>());
_updated = false;
}
- finally
- {
- _monitor.Unlock();
- }
}
public void
updated(Dictionary<string, string> dict)
{
- _monitor.Lock();
- try
+ lock(this)
{
_updated = true;
- _monitor.Notify();
- }
- finally
- {
- _monitor.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private bool _updated;
private Ice.PropertiesAdminPrx _serverProps;
- private IceUtilInternal.Monitor _monitor;
};
static void
diff --git a/cs/test/Ice/objects/Collocated.cs b/cs/test/Ice/objects/Collocated.cs
index cfc36f5a4ae..290b896626a 100644
--- a/cs/test/Ice/objects/Collocated.cs
+++ b/cs/test/Ice/objects/Collocated.cs
@@ -41,7 +41,17 @@ public class Client
try
{
- communicator = Ice.Util.initialize(ref args);
+ Ice.InitializationData data = new Ice.InitializationData();
+#if COMPACT
+ //
+ // When using Ice for .NET Compact Framework, we need to specify
+ // the assembly so that Ice can locate classes and exceptions.
+ //
+ data.properties = Ice.Util.createProperties();
+ data.properties.setProperty("Ice.FactoryAssemblies", "collocated");
+#endif
+
+ communicator = Ice.Util.initialize(ref args, data);
status = run(args, communicator);
}
catch(System.Exception ex)
diff --git a/cs/test/Ice/operations/OnewaysAMI.cs b/cs/test/Ice/operations/OnewaysAMI.cs
index 15db95ff522..0e75bcf79fb 100644
--- a/cs/test/Ice/operations/OnewaysAMI.cs
+++ b/cs/test/Ice/operations/OnewaysAMI.cs
@@ -30,39 +30,28 @@ class OnewaysAMI
public void check()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_called = false;
}
- finally
- {
- _m.Unlock();
- }
}
public void called()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_called);
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
private class AMI_MyClass_opVoidI : Test.AMI_MyClass_opVoid
diff --git a/cs/test/Ice/operations/OnewaysNewAMI.cs b/cs/test/Ice/operations/OnewaysNewAMI.cs
index eadefd9861d..7c08523e318 100644
--- a/cs/test/Ice/operations/OnewaysNewAMI.cs
+++ b/cs/test/Ice/operations/OnewaysNewAMI.cs
@@ -31,38 +31,27 @@ public class OnewaysNewAMI
public virtual void check()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_called = false;
}
- finally
- {
- _m.Unlock();
- }
}
public virtual void called()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_called);
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
private class Callback : CallbackBase
diff --git a/cs/test/Ice/operations/TwowaysAMI.cs b/cs/test/Ice/operations/TwowaysAMI.cs
index 54a0e962581..321a56c7f8d 100644
--- a/cs/test/Ice/operations/TwowaysAMI.cs
+++ b/cs/test/Ice/operations/TwowaysAMI.cs
@@ -31,39 +31,28 @@ public class TwowaysAMI
public virtual void check()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_called = false;
}
- finally
- {
- _m.Unlock();
- }
}
public virtual void called()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_called);
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
private class AMI_MyClass_opVoidI : Test.AMI_MyClass_opVoid
diff --git a/cs/test/Ice/operations/TwowaysNewAMI.cs b/cs/test/Ice/operations/TwowaysNewAMI.cs
index 5cefb553da5..0a240e6e15a 100644
--- a/cs/test/Ice/operations/TwowaysNewAMI.cs
+++ b/cs/test/Ice/operations/TwowaysNewAMI.cs
@@ -31,38 +31,27 @@ public class TwowaysNewAMI
public virtual void check()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_called = false;
}
- finally
- {
- _m.Unlock();
- }
}
public virtual void called()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_called);
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
private class Callback : CallbackBase
diff --git a/cs/test/Ice/retry/AllTests.cs b/cs/test/Ice/retry/AllTests.cs
index 41625f1cf1c..f3383ccc7d1 100644
--- a/cs/test/Ice/retry/AllTests.cs
+++ b/cs/test/Ice/retry/AllTests.cs
@@ -26,39 +26,28 @@ public class AllTests : TestCommon.TestApp
public void check()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_called = false;
}
- finally
- {
- _m.Unlock();
- }
}
public void called()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_called);
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
#if SILVERLIGHT
diff --git a/cs/test/Ice/seqMapping/Collocated.cs b/cs/test/Ice/seqMapping/Collocated.cs
index b88175299c6..58421059898 100644
--- a/cs/test/Ice/seqMapping/Collocated.cs
+++ b/cs/test/Ice/seqMapping/Collocated.cs
@@ -38,7 +38,16 @@ public class Collocated
try
{
- communicator = Ice.Util.initialize(ref args);
+ Ice.InitializationData data = new Ice.InitializationData();
+#if COMPACT
+ //
+ // When using Ice for .NET Compact Framework, we need to specify
+ // the assembly so that Ice can locate classes and exceptions.
+ //
+ data.properties = Ice.Util.createProperties();
+ data.properties.setProperty("Ice.FactoryAssemblies", "collocated");
+#endif
+ communicator = Ice.Util.initialize(ref args, data);
status = run(args, communicator);
}
catch(System.Exception ex)
diff --git a/cs/test/Ice/seqMapping/TwowaysAMI.cs b/cs/test/Ice/seqMapping/TwowaysAMI.cs
index c6501c17d33..bc1c90339d6 100644
--- a/cs/test/Ice/seqMapping/TwowaysAMI.cs
+++ b/cs/test/Ice/seqMapping/TwowaysAMI.cs
@@ -32,39 +32,28 @@ public class TwowaysAMI
public virtual void check()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_called = false;
}
- finally
- {
- _m.Unlock();
- }
}
public virtual void called()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_called);
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
private class AMI_MyClass_opAByteSI : Test.AMI_MyClass_opAByteS
diff --git a/cs/test/Ice/seqMapping/TwowaysNewAMI.cs b/cs/test/Ice/seqMapping/TwowaysNewAMI.cs
index 35ea4c019c6..63c3fdcec67 100644
--- a/cs/test/Ice/seqMapping/TwowaysNewAMI.cs
+++ b/cs/test/Ice/seqMapping/TwowaysNewAMI.cs
@@ -32,39 +32,28 @@ public class TwowaysNewAMI
public virtual void check()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_called = false;
}
- finally
- {
- _m.Unlock();
- }
}
public virtual void called()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_called);
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
private class Callback
diff --git a/cs/test/Ice/servantLocator/Collocated.cs b/cs/test/Ice/servantLocator/Collocated.cs
index c9182525c9f..8705db2d62f 100644
--- a/cs/test/Ice/servantLocator/Collocated.cs
+++ b/cs/test/Ice/servantLocator/Collocated.cs
@@ -41,7 +41,16 @@ public class Collocated
public static int Main(string[] args)
{
+ Ice.InitializationData data = new Ice.InitializationData();
+#if COMPACT
+ //
+ // When using Ice for .NET Compact Framework, we need to specify
+ // the assembly so that Ice can locate classes and exceptions.
+ //
+ data.properties = Ice.Util.createProperties();
+ data.properties.setProperty("Ice.FactoryAssemblies", "collocated");
+#endif
App app = new App();
- return app.main(args);
+ return app.main(args, data);
}
}
diff --git a/cs/test/Ice/slicing/exceptions/AllTests.cs b/cs/test/Ice/slicing/exceptions/AllTests.cs
index 76fbcc0deb3..93c4e1a9c58 100644
--- a/cs/test/Ice/slicing/exceptions/AllTests.cs
+++ b/cs/test/Ice/slicing/exceptions/AllTests.cs
@@ -27,39 +27,28 @@ public class AllTests : TestCommon.TestApp
public virtual void check()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_called = false;
}
- finally
- {
- _m.Unlock();
- }
}
public virtual void called()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_called);
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
private class RelayI : RelayDisp_
diff --git a/cs/test/Ice/slicing/objects/AllTests.cs b/cs/test/Ice/slicing/objects/AllTests.cs
index efffa420a4b..b58265eb790 100644
--- a/cs/test/Ice/slicing/objects/AllTests.cs
+++ b/cs/test/Ice/slicing/objects/AllTests.cs
@@ -28,39 +28,28 @@ public class AllTests : TestCommon.TestApp
public virtual void check()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_called = false;
}
- finally
- {
- _m.Unlock();
- }
}
public virtual void called()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_called);
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
private class PNodeI : PNode
diff --git a/cs/test/Ice/timeout/AllTests.cs b/cs/test/Ice/timeout/AllTests.cs
index 98419528b88..4717843ca8d 100644
--- a/cs/test/Ice/timeout/AllTests.cs
+++ b/cs/test/Ice/timeout/AllTests.cs
@@ -26,39 +26,28 @@ public class AllTests : TestCommon.TestApp
public virtual void check()
{
- _m.Lock();
- try
+ lock(this)
{
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
_called = false;
}
- finally
- {
- _m.Unlock();
- }
}
public virtual void called()
{
- _m.Lock();
- try
+ lock(this)
{
Debug.Assert(!_called);
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
#if SILVERLIGHT
diff --git a/cs/test/Ice/udp/AllTests.cs b/cs/test/Ice/udp/AllTests.cs
index b295101ee77..0014a961a4c 100644
--- a/cs/test/Ice/udp/AllTests.cs
+++ b/cs/test/Ice/udp/AllTests.cs
@@ -25,35 +25,24 @@ public class AllTests
{
public override void reply(Ice.Current current)
{
- _m.Lock();
- try
+ lock(this)
{
++_replies;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
public void reset()
{
- _m.Lock();
- try
+ lock(this)
{
_replies = 0;
}
- finally
- {
- _m.Unlock();
- }
}
public bool waitReply(int expectedReplies, long timeout)
{
- _m.Lock();
- try
+ lock(this)
{
long end = IceInternal.Time.currentMonotonicTimeMillis() + timeout;
while(_replies < expectedReplies)
@@ -61,7 +50,7 @@ public class AllTests
int delay = (int)(end - IceInternal.Time.currentMonotonicTimeMillis());
if(delay > 0)
{
- _m.TimedWait(delay);
+ System.Threading.Monitor.Wait(this, delay);
}
else
{
@@ -70,14 +59,9 @@ public class AllTests
}
return _replies == expectedReplies;
}
- finally
- {
- _m.Unlock();
- }
}
private int _replies = 0;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}
public static void allTests(Ice.Communicator communicator)
diff --git a/cs/test/IceBox/admin/TestI.cs b/cs/test/IceBox/admin/TestI.cs
index 7aaf6619ab3..065a8b7519e 100644
--- a/cs/test/IceBox/admin/TestI.cs
+++ b/cs/test/IceBox/admin/TestI.cs
@@ -27,18 +27,13 @@ public class TestFacetI : TestFacetDisp_, Ice.PropertiesAdminUpdateCallback
// updated() method is called. We block here to ensure that updated()
// gets called before we return the most recent set of changes.
//
- _m.Lock();
- try
+ lock(this)
{
while(!_called)
{
- _m.Wait();
+ System.Threading.Monitor.Wait(this);
}
}
- finally
- {
- _m.Unlock();
- }
_called = false;
return _changes;
@@ -46,20 +41,14 @@ public class TestFacetI : TestFacetDisp_, Ice.PropertiesAdminUpdateCallback
public void updated(Dictionary<string, string> changes)
{
- _m.Lock();
- try
+ lock(this)
{
_changes = changes;
_called = true;
- _m.Notify();
- }
- finally
- {
- _m.Unlock();
+ System.Threading.Monitor.Pulse(this);
}
}
private Dictionary<string, string> _changes;
private bool _called;
- private readonly IceUtilInternal.Monitor _m = new IceUtilInternal.Monitor();
}