}
e.curSocket = this;
- e.Worker.Init (this, null, e.AcceptCallback, SocketOperation.Accept);
- SocketAsyncCall sac = new SocketAsyncCall (e.Worker.Accept);
- sac.BeginInvoke (null, e.Worker.result);
+ Worker w = e.Worker;
+ w.Init (this, null, e.AcceptCallback, SocketOperation.Accept);
+ socket_pool_queue (w.Accept, w.result);
return true;
}
#endif
-
// Creates a new system socket, returning the handle
[MethodImplAttribute(MethodImplOptions.InternalCall)]
private extern static IntPtr Accept_internal(IntPtr sock, out int error, bool blocking);
SocketAsyncResult req = new SocketAsyncResult (this, state, callback, SocketOperation.Accept);
Worker worker = new Worker (req);
- SocketAsyncCall sac = new SocketAsyncCall (worker.Accept);
- sac.BeginInvoke (null, req);
- return(req);
+ socket_pool_queue (worker.Accept, req);
+ return req;
}
public IAsyncResult BeginAccept (int receiveSize,
SocketAsyncResult req = new SocketAsyncResult (this, state, callback, SocketOperation.AcceptReceive);
Worker worker = new Worker (req);
- SocketAsyncCall sac = new SocketAsyncCall (worker.AcceptReceive);
-
req.Buffer = new byte[receiveSize];
req.Offset = 0;
req.Size = receiveSize;
req.SockFlags = SocketFlags.None;
-
- sac.BeginInvoke (null, req);
- return(req);
+ socket_pool_queue (worker.AcceptReceive, req);
+ return req;
}
public IAsyncResult BeginAccept (Socket acceptSocket,
SocketAsyncResult req = new SocketAsyncResult (this, state, callback, SocketOperation.AcceptReceive);
Worker worker = new Worker (req);
- SocketAsyncCall sac = new SocketAsyncCall (worker.AcceptReceive);
-
req.Buffer = new byte[receiveSize];
req.Offset = 0;
req.Size = receiveSize;
req.SockFlags = SocketFlags.None;
req.AcceptSocket = acceptSocket;
-
- sac.BeginInvoke (null, req);
+ socket_pool_queue (worker.AcceptReceive, req);
return(req);
}
// continue asynch
connected = false;
Worker worker = new Worker (req);
- SocketAsyncCall sac = new SocketAsyncCall (worker.Connect);
- sac.BeginInvoke (null, req);
+ socket_pool_queue (worker.Connect, req);
}
return(req);
connected = false;
Worker worker = new Worker (req);
- SocketAsyncCall sac = new SocketAsyncCall (worker.Connect);
- sac.BeginInvoke (null, req);
+ socket_pool_queue (worker.Connect, req);
return(req);
}
req.ReuseSocket = reuseSocket;
Worker worker = new Worker (req);
- SocketAsyncCall sac = new SocketAsyncCall (worker.Disconnect);
- sac.BeginInvoke (null, req);
+ socket_pool_queue (worker.Disconnect, req);
return(req);
}
req.Size = size;
req.SockFlags = socket_flags;
Worker worker = new Worker (req);
+ int count;
lock (readQ) {
readQ.Enqueue (worker);
- if (readQ.Count == 1) {
- SocketAsyncCall sac = new SocketAsyncCall (worker.Receive);
- sac.BeginInvoke (null, req);
- }
+ count = readQ.Count;
}
-
+ if (count == 1)
+ socket_pool_queue (worker.Receive, req);
return req;
}
req.Buffers = buffers;
req.SockFlags = socketFlags;
Worker worker = new Worker (req);
+ int count;
lock(readQ) {
readQ.Enqueue (worker);
- if (readQ.Count == 1) {
- SocketAsyncCall sac = new SocketAsyncCall (worker.ReceiveGeneric);
- sac.BeginInvoke (null, req);
- }
+ count = readQ.Count;
}
-
- return(req);
+ if (count == 1)
+ socket_pool_queue (worker.ReceiveGeneric, req);
+ return req;
}
[CLSCompliant (false)]
req.SockFlags = socket_flags;
req.EndPoint = remote_end;
Worker worker = new Worker (req);
+ int count;
lock (readQ) {
readQ.Enqueue (worker);
- if (readQ.Count == 1) {
- SocketAsyncCall sac = new SocketAsyncCall (worker.ReceiveFrom);
- sac.BeginInvoke (null, req);
- }
+ count = readQ.Count;
}
+ if (count == 1)
+ socket_pool_queue (worker.ReceiveFrom, req);
return req;
}
req.Size = size;
req.SockFlags = socket_flags;
Worker worker = new Worker (req);
+ int count;
lock (writeQ) {
writeQ.Enqueue (worker);
- if (writeQ.Count == 1) {
- SocketAsyncCall sac = new SocketAsyncCall (worker.Send);
- sac.BeginInvoke (null, req);
- }
+ count = writeQ.Count;
}
+ if (count == 1)
+ socket_pool_queue (worker.Send, req);
return req;
}
req.Buffers = buffers;
req.SockFlags = socketFlags;
Worker worker = new Worker (req);
+ int count;
lock (writeQ) {
writeQ.Enqueue (worker);
- if (writeQ.Count == 1) {
- SocketAsyncCall sac = new SocketAsyncCall (worker.SendGeneric);
- sac.BeginInvoke (null, req);
- }
+ count = writeQ.Count;
}
-
- return(req);
+ if (count == 1)
+ socket_pool_queue (worker.SendGeneric, req);
+ return req;
}
[CLSCompliant (false)]
req.SockFlags = socket_flags;
req.EndPoint = remote_end;
Worker worker = new Worker (req);
+ int count;
lock (writeQ) {
writeQ.Enqueue (worker);
- if (writeQ.Count == 1) {
- SocketAsyncCall sac = new SocketAsyncCall (worker.SendTo);
- sac.BeginInvoke (null, req);
- }
+ count = writeQ.Count;
}
+ if (count == 1)
+ socket_pool_queue (worker.SendTo, req);
return req;
}
e.curSocket = this;
e.Worker.Init (this, null, e.DisconnectCallback, SocketOperation.Disconnect);
- SocketAsyncCall sac = new SocketAsyncCall (e.Worker.Disconnect);
- sac.BeginInvoke (null, e.Worker.result);
+ socket_pool_queue (e.Worker.Disconnect, e.Worker.result);
return true;
}
#endif
res.EndPoint = e.RemoteEndPoint;
res.SockFlags = e.SocketFlags;
Worker worker = new Worker (e);
+ int count;
lock (readQ) {
readQ.Enqueue (worker);
- if (readQ.Count == 1) {
- SocketAsyncCall sac = new SocketAsyncCall (e.Worker.ReceiveFrom);
- sac.BeginInvoke (null, res);
- }
+ count = readQ.Count;
}
+ if (count == 1)
+ socket_pool_queue (e.Worker.ReceiveFrom, res);
return true;
}
#endif
res.SockFlags = e.SocketFlags;
res.EndPoint = e.RemoteEndPoint;
Worker worker = new Worker (e);
+ int count;
lock (writeQ) {
writeQ.Enqueue (worker);
- if (writeQ.Count == 1) {
- SocketAsyncCall sac = new SocketAsyncCall (e.Worker.SendTo);
- sac.BeginInvoke (null, res);
- }
+ count = writeQ.Count;
}
- // We always return true for now
+ if (count == 1)
+ socket_pool_queue (e.Worker.SendTo, res);
return true;
}
#endif
public void Init (Socket sock, object state, AsyncCallback callback, SocketOperation operation)
{
this.Sock = sock;
- this.blocking = sock.blocking;
- this.handle = sock.socket;
+ if (sock != null) {
+ this.blocking = sock.blocking;
+ this.handle = sock.socket;
+ } else {
+ this.blocking = true;
+ this.handle = IntPtr.Zero;
+ }
this.state = state;
this.callback = callback;
this.operation = operation;
}
if (sac != null)
- sac.BeginInvoke (null, worker.result);
+ Socket.socket_pool_queue (sac, worker.result);
}
if (callback != null)
}
if (result.Size > 0) {
- SocketAsyncCall sac = new SocketAsyncCall (this.Send);
- sac.BeginInvoke (null, result);
+ Socket.socket_pool_queue (this.Send, result);
return; // Have to finish writing everything. See bug #74475.
}
result.Total = send_so_far;
UpdateSendValues (total);
if (result.Size > 0) {
- SocketAsyncCall sac = new SocketAsyncCall (this.SendTo);
- sac.BeginInvoke (null, result);
+ Socket.socket_pool_queue (this.SendTo, result);
return; // Have to finish writing everything. See bug #74475.
}
result.Total = send_so_far;
}
res.SockFlags = e.SocketFlags;
Worker worker = new Worker (e);
+ int count;
lock (readQ) {
readQ.Enqueue (worker);
- if (readQ.Count == 1) {
- SocketAsyncCall sac = new SocketAsyncCall (e.Worker.Receive);
- sac.BeginInvoke (null, res);
- }
+ count = readQ.Count;
+ }
+ if (count == 1) {
+ // Receive takes care of ReceiveGeneric
+ socket_pool_queue (e.Worker.Receive, res);
}
+
return true;
}
}
res.SockFlags = e.SocketFlags;
Worker worker = new Worker (e);
+ int count;
lock (writeQ) {
writeQ.Enqueue (worker);
- if (writeQ.Count == 1) {
- SocketAsyncCall sac = new SocketAsyncCall (e.Worker.Send);
- sac.BeginInvoke (null, res);
- }
+ count = writeQ.Count;
+ }
+ if (count == 1) {
+ // Send takes care of SendGeneric
+ socket_pool_queue (e.Worker.Send, res);
}
return true;
}
end_point = req.EndPoint;
return req.Total;
}
+
+ [MethodImplAttribute(MethodImplOptions.InternalCall)]
+ static extern void socket_pool_queue (SocketAsyncCall d, SocketAsyncResult r);
}
}