Re: Lock.lock("info")..
David Holmes via Concurrency-interest <[email protected]> Mon, 22 Nov 2021 19:20:41 +1000
| Newsgroups | gmane.comp.java.jsr.166-concurrency |
|---|---|
| Message-ID | <[email protected]> |
This is a multipart message in MIME format. --===============2786078284199156062== Content-Type: multipart/alternative; boundary="----=_NextPart_000_0181_01D7DFD6.0A731AB0" Content-Language: en-au This is a multipart message in MIME format. ------=_NextPart_000_0181_01D7DFD6.0A731AB0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Kedar, =20 I added back the c-I list. =20 So IIUC you want to store information about the last operation with the = lock, so that next time if you can=E2=80=99t get it (?) because teardown = has not finished, you could query the lock to see what the previous = operation was, and report that back. In other words your lock is the = only common object you have for different messages in the same session = so you want to use it to channel the data through. In such a situation I = would expect you to map a session id to a Session object which includes = the lock and any other data about the session you might want to track. = If that is the =E2=80=9CHolder=E2=80=9D that you previously referred to = then that is the best way to do this IMO. =20 It isn=E2=80=99t the job of a Lock to act as a data repository, so I = would not consider adding the kind of API you have suggested. =20 Cheers, David =20 From: Kedar C. Raybagkar <[email protected]>=20 Sent: Monday, 22 November 2021 6:18 PM To: [email protected] Subject: Re: [concurrency-interest] Lock.lock("info").. =20 Consider a simple servlet. =20 This servlet creates an AsyncFuture and waits for say 3 seconds max = before sending the response out to the caller. If the response is = generated within 3 seconds it is sent out, else we send a long running = response (with reference to the future) to the caller. The caller if = receives the response it displays it else if it finds a long running = response then again calls the server by passing the reference id. =20 Now we have this future execute the job in two distinct ways. #1 waits = till the entire operation is complete and #2 with no wait for the tear = down process. =20 Teardown process serializes some data and it takes some time before it = completes but the response is already generated and can be sent to the = caller. =20 In case of #2 what we do is on the queue we push the response early on = and then continue to do teardown. The caller waits on the queue and as = soon as the response is received it returns that to the caller. =20 Usually the user takes time to send further requests to the server and = in normal scenarios the tear down is finished by the time the next = request comes. When the next request comes to the server we have to = ensure that the prior requests teardown is complete. So we have used = Lock to latch on and release it once teardown is complete. The latch is = acquired as per the session (UUID reference) so that when the next = request comes it gets the same latch and waits on the latch to be = released. =20 As we need to keep all these Locks in a map based on the UUID (session = identifier) we need to hold on to the encapsulated lock DTO that holds = the purpose of what was being done before. =20 Hope I am able to explain it to your satisfaction. =20 Thanks & Regards, =20 =20 On Mon, 22 Nov 2021 at 12:01, David Holmes <[email protected] = <mailto:[email protected]> > wrote: Why do you need a Holder object for the lock and condition? The lock and = condition belong in the object whose state they are guarding and = interacting with. If you are using external synchronization you wont = have an encapsulated lock/condition but the code using the = lock/condition has to know what it is actually dealing with and so that = code can report that information. =20 David =20 From: Kedar C. Raybagkar <[email protected] = <mailto:[email protected]> >=20 Sent: Monday, 22 November 2021 4:23 PM To: [email protected] <mailto:[email protected]>=20 Cc: [email protected] = <mailto:[email protected]>=20 Subject: Re: [concurrency-interest] Lock.lock("info").. =20 Thank you, David. =20 That is what I have been doing but instead of having to encapsulate into = a separate holder object I thought it might be a good idea to have some = API directly available. As encapsulation also results in having a Value = Object with hashcode and equals being overridden and then keeping them = in a map with thread ids. This is already within the lock; just an = additional string or object parameter may help solve the problem. =20 Regards, -Kedar. =20 On Mon, 22 Nov 2021 at 11:28, David Holmes <[email protected] = <mailto:[email protected]> > wrote: Hi Kedar, =20 The Lock and Condition should be encapsulated inside the object that = needs them, and that object can provide whatever additional information = the callers needs on its own methods. =20 Cheers, David =20 From: Concurrency-interest <[email protected] = <mailto:[email protected]> > On Behalf Of Kedar = C. Raybagkar via Concurrency-interest Sent: Monday, 22 November 2021 3:43 PM To: [email protected] = <mailto:[email protected]>=20 Subject: [concurrency-interest] Lock.lock("info").. =20 Hi, =20 Can we have something API where we can provide why we have acquired a = lock so that when waiting on a condition if timed out we can fetch the = info and return it to the caller? =20 Regards, -Kedar. ------=_NextPart_000_0181_01D7DFD6.0A731AB0 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <html xmlns:v=3D"urn:schemas-microsoft-com:vml" = xmlns:o=3D"urn:schemas-microsoft-com:office:office" = xmlns:w=3D"urn:schemas-microsoft-com:office:word" = xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" = xmlns=3D"http://www.w3.org/TR/REC-html40"><head><meta = http-equiv=3DContent-Type content=3D"text/html; charset=3Dutf-8"><meta = name=3DGenerator content=3D"Microsoft Word 15 (filtered = medium)"><style><!-- /* Font Definitions */ @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;} @font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; font-size:11.0pt; font-family:"Calibri",sans-serif;} a:link, span.MsoHyperlink {mso-style-priority:99; color:blue; text-decoration:underline;} span.EmailStyle18 {mso-style-type:personal-reply; font-family:"Calibri",sans-serif; color:windowtext;} .MsoChpDefault {mso-style-type:export-only; font-family:"Calibri",sans-serif; mso-fareast-language:EN-US;} @page WordSection1 {size:612.0pt 792.0pt; margin:72.0pt 72.0pt 72.0pt 72.0pt;} div.WordSection1 {page:WordSection1;} --></style><!--[if gte mso 9]><xml> <o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" /> </xml><![endif]--><!--[if gte mso 9]><xml> <o:shapelayout v:ext=3D"edit"> <o:idmap v:ext=3D"edit" data=3D"1" /> </o:shapelayout></xml><![endif]--></head><body lang=3DEN-AU link=3Dblue = vlink=3Dpurple style=3D'word-wrap:break-word'><div = class=3DWordSection1><p class=3DMsoNormal><span = style=3D'mso-fareast-language:EN-US'>Hi Kedar,<o:p></o:p></span></p><p = class=3DMsoNormal><span = style=3D'mso-fareast-language:EN-US'><o:p> </o:p></span></p><p = class=3DMsoNormal><span style=3D'mso-fareast-language:EN-US'>I added = back the c-I list.<o:p></o:p></span></p><p class=3DMsoNormal><span = style=3D'mso-fareast-language:EN-US'><o:p> </o:p></span></p><p = class=3DMsoNormal><span style=3D'mso-fareast-language:EN-US'>So IIUC you = want to store information about the last operation with the lock, so = that next time if you can=E2=80=99t get it (?) because teardown has not = finished, you could query the lock to see what the previous operation = was, and report that back. In other words your lock is the only common = object you have for different messages in the same session so you want = to use it to channel the data through. In such a situation I would = expect you to map a session id to a Session object which includes the = lock and any other data about the session you might want to track. If = that is the =E2=80=9CHolder=E2=80=9D that you previously referred to = then that is the best way to do this IMO.<o:p></o:p></span></p><p = class=3DMsoNormal><span = style=3D'mso-fareast-language:EN-US'><o:p> </o:p></span></p><p = class=3DMsoNormal><span style=3D'mso-fareast-language:EN-US'>It = isn=E2=80=99t the job of a Lock to act as a data repository, so I would = not consider adding the kind of API you have = suggested.<o:p></o:p></span></p><p class=3DMsoNormal><span = style=3D'mso-fareast-language:EN-US'><o:p> </o:p></span></p><p = class=3DMsoNormal><span = style=3D'mso-fareast-language:EN-US'>Cheers,<o:p></o:p></span></p><p = class=3DMsoNormal><span = style=3D'mso-fareast-language:EN-US'>David<o:p></o:p></span></p><p = class=3DMsoNormal><span = style=3D'mso-fareast-language:EN-US'><o:p> </o:p></span></p><div = style=3D'border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm = 0cm 0cm'><p class=3DMsoNormal><b><span = lang=3DEN-US>From:</span></b><span lang=3DEN-US> Kedar C. Raybagkar = <[email protected]> <br><b>Sent:</b> Monday, 22 November = 2021 6:18 PM<br><b>To:</b> [email protected]<br><b>Subject:</b> Re: = [concurrency-interest] = Lock.lock("info")..<o:p></o:p></span></p></div><p = class=3DMsoNormal><o:p> </o:p></p><div><p = class=3DMsoNormal>Consider a simple servlet.<o:p></o:p></p><div><p = class=3DMsoNormal><o:p> </o:p></p></div><div><p = class=3DMsoNormal>This servlet creates an AsyncFuture and waits for say = 3 seconds max before sending the response out to the caller. If the = response is generated within 3 seconds it is sent out, else we send a = long running response (with reference to the future) to the caller. The = caller if receives the response it displays it else if it finds a long = running response then again calls the server by passing the reference = id.<o:p></o:p></p></div><div><p = class=3DMsoNormal><o:p> </o:p></p></div><div><p = class=3DMsoNormal>Now we have this future execute the job in two = distinct ways. #1 waits till the entire operation is complete and #2 = with no wait for the tear down process.<o:p></o:p></p></div><div><p = class=3DMsoNormal><o:p> </o:p></p></div><div><p = class=3DMsoNormal>Teardown process serializes some data and it takes = some time before it completes but the response is already generated = and can be sent to the caller.<o:p></o:p></p></div><div><p = class=3DMsoNormal><o:p> </o:p></p></div><div><p = class=3DMsoNormal>In case of #2 what we do is on the queue we push the = response early on and then continue to do teardown. The caller waits on = the queue and as soon as the response is received it returns = that to the caller.<o:p></o:p></p></div><div><p = class=3DMsoNormal><o:p> </o:p></p></div><div><p = class=3DMsoNormal>Usually the user takes time to send further requests = to the server and in normal scenarios the tear down is finished by the = time the next request comes. When the next request comes to the server = we have to ensure that the prior requests teardown is complete. So we = have used Lock to latch on and release it once teardown is complete. The = latch is acquired as per the session (UUID reference) so that when the = next request comes it gets the same latch and waits on the latch to be = released.<o:p></o:p></p></div><div><p = class=3DMsoNormal><o:p> </o:p></p></div><div><p = class=3DMsoNormal>As we need to keep all these Locks in a map based on = the UUID (session identifier) we need to hold on to the encapsulated = lock DTO that holds the purpose of what was being done = before.<o:p></o:p></p></div><div><p = class=3DMsoNormal><o:p> </o:p></p></div><div><p = class=3DMsoNormal>Hope I am able to explain it to your = satisfaction.<o:p></o:p></p></div><div><p = class=3DMsoNormal><o:p> </o:p></p></div><div><p = class=3DMsoNormal>Thanks & Regards,<o:p></o:p></p></div><div><p = class=3DMsoNormal><o:p> </o:p></p></div></div><p = class=3DMsoNormal><o:p> </o:p></p><div><div><p class=3DMsoNormal>On = Mon, 22 Nov 2021 at 12:01, David Holmes <<a = href=3D"mailto:[email protected]">[email protected]</a>>= wrote:<o:p></o:p></p></div><blockquote = style=3D'border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm = 6.0pt;margin-left:4.8pt;margin-right:0cm'><div><div><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Why do you = need a Holder object for the lock and condition? The lock and condition = belong in the object whose state they are guarding and interacting with. = If you are using external synchronization you wont have an encapsulated = lock/condition but the code using the lock/condition has to know what it = is actually dealing with and so that code can report that = information.<o:p></o:p></p><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p><= /o:p></p><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>David<o:p></= o:p></p><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p><= /o:p></p><div style=3D'border:none;border-top:solid #E1E1E1 = 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span = lang=3DEN-US>From:</span></b><span lang=3DEN-US> Kedar C. Raybagkar = <<a href=3D"mailto:[email protected]" = target=3D"_blank">[email protected]</a>> <br><b>Sent:</b> = Monday, 22 November 2021 4:23 PM<br><b>To:</b> <a = href=3D"mailto:[email protected]" = target=3D"_blank">[email protected]</a><br><b>Cc:</b> <a = href=3D"mailto:[email protected]" = target=3D"_blank">[email protected]</a><br><b>Subject:</= b> Re: [concurrency-interest] = Lock.lock("info")..</span><o:p></o:p></p></div><p = class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p><= /o:p></p><div><div><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Thank you, = David.<o:p></o:p></p></div><div><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p><= /o:p></p></div><div><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>That is = what I have been doing but instead of having to encapsulate into a = separate holder object I thought it might be a good idea to have some = API directly available. As encapsulation also results in having a = Value Object with hashcode and equals being overridden and then keeping = them in a map with thread ids. This is already within the lock; just an = additional string or object parameter may help solve = the problem.<o:p></o:p></p></div><div><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p><= /o:p></p></div><div><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Regards,<o:p= ></o:p></p></div><div><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>-Kedar.<o:p>= </o:p></p></div></div><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p><= /o:p></p><div><div><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>On Mon, 22 = Nov 2021 at 11:28, David Holmes <<a = href=3D"mailto:[email protected]" = target=3D"_blank">[email protected]</a>> = wrote:<o:p></o:p></p></div><blockquote = style=3D'border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm = 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;margin-bottom:5= .0pt'><div><div><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Hi = Kedar,<o:p></o:p></p><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p><= /o:p></p><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>The Lock = and Condition should be encapsulated inside the object that needs them, = and that object can provide whatever additional information the callers = needs on its own methods.<o:p></o:p></p><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p><= /o:p></p><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Cheers,<o:p>= </o:p></p><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>David<o:p></= o:p></p><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p><= /o:p></p><div style=3D'border:none;border-top:solid #E1E1E1 = 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'><b><span = lang=3DEN-US>From:</span></b><span lang=3DEN-US> Concurrency-interest = <<a href=3D"mailto:[email protected]" = target=3D"_blank">[email protected]</a>> = <b>On Behalf Of </b>Kedar C. Raybagkar via = Concurrency-interest<br><b>Sent:</b> Monday, 22 November 2021 3:43 = PM<br><b>To:</b> <a href=3D"mailto:[email protected]" = target=3D"_blank">[email protected]</a><br><b>Subject:</= b> [concurrency-interest] = Lock.lock("info")..</span><o:p></o:p></p></div><p = class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p><= /o:p></p><div><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Hi,<o:p></o:= p></p><div><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p><= /o:p></p></div><div><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Can we have = something API where we can provide why we have acquired a lock so that = when waiting on a condition if timed out we can fetch the info and = return it to the caller?<o:p></o:p></p></div><div><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p><= /o:p></p></div><div><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Regards,<o:p= ></o:p></p></div><div><p class=3DMsoNormal = style=3D'mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>-Kedar.<o:p>= </o:p></p></div></div></div></div></blockquote></div></div></div></blockq= uote></div></div></body></html> ------=_NextPart_000_0181_01D7DFD6.0A731AB0-- --===============2786078284199156062== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Concurrency-interest mailing list [email protected] http://cs.oswego.edu/mailman/listinfo/concurrency-interest --===============2786078284199156062==--