Return-Path: X-Original-To: apmail-tomcat-users-archive@www.apache.org Delivered-To: apmail-tomcat-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3EBEE10DEF for ; Tue, 22 Oct 2013 11:17:14 +0000 (UTC) Received: (qmail 3722 invoked by uid 500); 22 Oct 2013 11:17:08 -0000 Delivered-To: apmail-tomcat-users-archive@tomcat.apache.org Received: (qmail 3599 invoked by uid 500); 22 Oct 2013 11:17:05 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 3587 invoked by uid 99); 22 Oct 2013 11:17:03 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Oct 2013 11:17:03 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of bob.deremer@thingworx.com designates 207.46.163.243 as permitted sender) Received: from [207.46.163.243] (HELO na01-by2-obe.outbound.protection.outlook.com) (207.46.163.243) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Oct 2013 11:16:59 +0000 Received: from BLUPR06MB193.namprd06.prod.outlook.com (10.242.191.143) by BLUPR06MB193.namprd06.prod.outlook.com (10.242.191.143) with Microsoft SMTP Server (TLS) id 15.0.785.10; Tue, 22 Oct 2013 11:16:35 +0000 Received: from BLUPR06MB193.namprd06.prod.outlook.com ([169.254.13.240]) by BLUPR06MB193.namprd06.prod.outlook.com ([169.254.13.179]) with mapi id 15.00.0785.001; Tue, 22 Oct 2013 11:16:35 +0000 From: Bob DeRemer To: Tomcat Users List Subject: RE: is the Tomcat-7 WsRemoteEndpointImplBase send methods threadsafe, or should we be synchronizing until the Future<>.get() returns? Thread-Topic: is the Tomcat-7 WsRemoteEndpointImplBase send methods threadsafe, or should we be synchronizing until the Future<>.get() returns? Thread-Index: Ac7OsIAx2veJbB5nS6ygDA0WKRmqMQADTVWAAAnWJgAADL6I0A== Date: Tue, 22 Oct 2013 11:16:25 +0000 Message-ID: <0dd5ebdefe324613a8eb76123cd62829@BLUPR06MB193.namprd06.prod.outlook.com> References: <622c3a58d5d442ad8c53d10065a12dc7@BLUPR06MB193.namprd06.prod.outlook.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [98.237.127.73] x-forefront-prvs: 00073DB75F x-forefront-antispam-report: SFV:NSPM;SFS:(24454002)(13464003)(252514010)(51704005)(377454003)(189002)(199002)(83322001)(80976001)(19580395003)(19580405001)(77096001)(53806001)(74366001)(81342001)(51856001)(76796001)(15975445006)(74706001)(69226001)(81542001)(76576001)(54356001)(76786001)(46102001)(33646001)(56816003)(83072001)(4396001)(66066001)(65816001)(80022001)(74662001)(47446002)(74502001)(31966008)(81816001)(59766001)(79102001)(63696002)(77982001)(76482001)(74876001)(85306002)(74316001)(81686001)(47976001)(56776001)(49866001)(50986001)(47736001)(54316002)(24736002);DIR:OUT;SFP:;SCL:1;SRVR:BLUPR06MB193;H:BLUPR06MB193.namprd06.prod.outlook.com;CLIP:98.237.127.73;FPR:;RD:InfoNoRecords;MX:1;A:1;LANG:en; Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: thingworx.com X-Virus-Checked: Checked by ClamAV on apache.org > -----Original Message----- > From: Niki Dokovski [mailto:nickytd@gmail.com] > Sent: Tuesday, October 22, 2013 1:11 AM > To: Tomcat Users List > Subject: Re: is the Tomcat-7 WsRemoteEndpointImplBase send methods > threadsafe, or should we be synchronizing until the Future<>.get() return= s? >=20 > On Tue, Oct 22, 2013 at 3:29 AM, David Bullock < > david.bullock@machaira.com.au> wrote: >=20 > > Hi Bob, > > > > > I tried searching the javadocs of RemoteEndpoint.Async and > > > associated > > interfaces, but could not find anything describing the threadsafe > > nature (existing or not). It appears that the spec lets the > > implementation determine how to handle stuff under the covers. This > > is fine, but we just need to understand what that means to > > multi-threaded code that wants to send messages. > > >=20 > JSR 356 Specification Section 5.1 Threading Consideration discusses the t= opic. > In particular; > [WSC-5.1-2] - "the implementation must not invoke an endpoint instance wi= th > more than one thread per peer at a time." > [WSC-5.1-4] - "a websocket endpoint instance is never called by more than= one > container thread at a time per peer." >=20 > cheers >=20 Thank you, Niki, for the spec clarification bob >=20 > > > > I'd have thought that where an interface doesn't declare that it is > > threadsafe, one cannot assume that it will be. Further, if a > > RemoteEndpoint represents 'the peer of a web socket conversation', > > then a RemoteEndpoint, like a conversation, can surely support only a > > single 'conversation state'? > > > > IMHO, the correct choice is for each thread to have its own > > RemoteEndpoint. If the protocol being used happens to multiplex > > multiple conversations to/from different endpoints over the same > > TCP/UDP socket (for example), then the plumbing will do the > > appropriate synchronization at that point - there would be no > > advantage (and possibly some big disadvantages) for you to do your own > > synchronization. Critically, a RemoteEndpoint does not necessarily > > represent a 'heavyweight' object like a Socket, and you should not be > > at pains to manage your own pool of them, nor necessarily (unless it > > made sense for application logic) to have a queue of messages which is > > dispatched from a single thread. > > > > However, I do think that many JSR's which ought to know better are > > very lame about thread-safety guarantees for application authors, and > > that more needs to be said in API documentation about patterns for > > concurrent usage. I encourage you to lobby your particular JSR of use > > to include this information in future releases of the specification. > > I did my bit recently at https://java.net/jira/browse/SERVLET_SPEC-81 > > > > cheers, > > David Bullock > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > > For additional commands, e-mail: users-help@tomcat.apache.org > > > > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org For additional commands, e-mail: users-help@tomcat.apache.org