I may not fully understand your proposal. Could you file a JIRA and a small sample code change for idea?
Tsz-Wo On Fri, Sep 20, 2024 at 1:49 AM ka yuu <[email protected]> wrote: > Sorry, sze, Please see this email, last email has some format problems. > > > sze, thanks for your reply > > > That's right. The ReferenceCount stored in the cahe needs special handling. > > > we need to invoke retain() before PutOperation, invoke release() after > RemoveOperation from cache. > The GetOperation can still use try-finally. > > > Since Java does not support RAII, we can simulate this feature. Although > this large amount of try-finally will make the code less elegant. This > method provides us with the convenience of resource acquisition and > release, making it easier to troubleshoot problems > > > what do you think? > > ka yuu <[email protected]> 于2024年9月20日周五 16:44写道: > >> sze, thanks for your reply >> That's right. The ReferenceCount stored in the cahe needs special >> handling. >> we need to invoke retain() before PutOperation, invoke release() after >> RemoveOperation from cache. >> The GetOperation can still use try-finally. >> Since Java does not support RAII, we can simulate this feature. Although >> this large amount of try-finally will make the code less elegant. This >> method provides us with the convenience of resource acquisition and >> release, making it easier to troubleshoot problems >> what do you think? >> >> Tsz Wo Sze <[email protected]> 于2024年9月20日周五 11:59写道: >> >>> Hi, >>> >>> When possible, we should use try-finally. However, there are cases >>> where the object can be stored in a cache and it will be released later. >>> Then, we cannot use try-finally. >>> >>> Tsz-Wo >>> >>> >>> >>> On Thu, Sep 19, 2024 at 7:59 PM ka yuu <[email protected]> wrote: >>> >>>> Hi ratis commuity! >>>> >>>> Can we refer to the idea of RAII to handle ReferenceObject? >>>> >>>> >>>> i.e.: >>>> * function(ReferenceObject<T> requestRef) {* >>>> * ...* >>>> * try {* >>>> * requestReq.retain();* >>>> * ... * >>>> * } finaly {* >>>> * requestRef.release();* >>>> * }* >>>> * }* >>>> >>>> >>>> In this way, we should not miss release or retain every time we use >>>> ReferenceCount >>>> >>>
