[Mono-dev] Async IO/Completion ports/threads
Joe Dluzen
jdluzen at gmail.com
Mon Aug 29 12:30:09 EDT 2011
Hi all,
I was looking at async IO support in Mono, which does seem to use
epoll. I found some sample code at
http://stackoverflow.com/questions/2575404/asynchronous-pages-in-the-asp-net-framework-where-are-the-other-threads-and-how/2576601#2576601,
and it does seem to work under Windows .NET, the number of availableIO
threads is 1 less than maxIO. But under Mono 2.10.3 on Win x64, it has
1 less regular worker threads. Mono 2.10.3 on a Ubuntu 11.04 VM is the
same. A bug? Or should I try something else?
Thanks,
Joe
Slightly modified code:
using System;
using System.IO;
using System.Net;
using System.Threading;
namespace IoCompletionPortTest
{
class Program
{
static WebRequest request;
static IAsyncResult BeginDownload(object sender, EventArgs e,
AsyncCallback cb, object state)
{
request = WebRequest.Create("http://www.google.com");
return request.BeginGetResponse(cb, state);
}
static void Main(string[] args)
{
IAsyncResult r = BeginDownload(null, null, (ar) =>
{
int maxWorkers, maxIO, availableWorkers, availableIO;
ThreadPool.GetMaxThreads(out maxWorkers, out maxIO);
ThreadPool.GetAvailableThreads(out
availableWorkers, out availableIO);
string html;
using (WebResponse response = request.EndGetResponse(ar))
using (StreamReader reader = new
StreamReader(response.GetResponseStream()))
html = reader.ReadToEnd();
Console.WriteLine("{0} out of {1} workers, {2} out
of {3} IOs", availableWorkers, maxWorkers, availableIO, maxIO);
}, null);
Console.ReadLine();
}
}
}
More information about the Mono-devel-list
mailing list