Deutsch English Français Italiano |
<TO6cnaz7jdFtBbv7nZ2dnZfqn_WdnZ2d@giganews.com> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 22 Apr 2024 17:05:51 +0000 Subject: Re: Meta: a usenet server just for sci.math Newsgroups: sci.math,news.software.nntp,comp.programming.threads References: <8f7c0783-39dd-4f48-99bf-f1cf53b17dd9@googlegroups.com> <51605ff6-f18f-48c5-8e83-0397632556aen@googlegroups.com> <b0c4589a-f222-457e-95b3-437c0721c2a2n@googlegroups.com> <5a48e832-3573-4c33-b9cb-d112f01b733bn@googlegroups.com> <8wWdnVqZk54j3Fj4nZ2dnZfqnPGdnZ2d@giganews.com> <MY-cnRuWkPoIhFr4nZ2dnZfqnPSdnZ2d@giganews.com> <NqqdnbEz-KTJTlr4nZ2dnZfqnPudnZ2d@giganews.com> <FqOcnYWdRfEI2lT4nZ2dnZfqn_SdnZ2d@giganews.com> <NVudnVAqkJ0Sk1D4nZ2dnZfqn_idnZ2d@giganews.com> <RuKdnfj4NM2rlkz4nZ2dnZfqn_qdnZ2d@giganews.com> <HfCdnROSvfir-E_4nZ2dnZfqnPWdnZ2d@giganews.com> <FLicnRkOg7SrWU_4nZ2dnZfqnPadnZ2d@giganews.com> <v7ecnUsYY7bW40j4nZ2dnZfqnPudnZ2d@giganews.com> <q7-dnR2O9OsAAH74nZ2dnZfqnPhg4p2d@giganews.com> <Hp-cnUAirtFtx2P4nZ2dnZfqnPednZ2d@giganews.com> <MDKdnRJpQ_Q87Z77nZ2dnZfqn_idnZ2d@giganews.com> <-bOdnWSSIMUKcZn7nZ2dnZfqnPednZ2d@giganews.com> <CoCdnYJuP9p8aob7nZ2dnZfqnPudnZ2d@giganews.com> <bJ6dna6Zv4r7lbn7nZ2dnZfqn_WdnZ2d@giganews.com> From: Ross Finlayson <ross.a.finlayson@gmail.com> Date: Mon, 22 Apr 2024 10:06:02 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <bJ6dna6Zv4r7lbn7nZ2dnZfqn_WdnZ2d@giganews.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <TO6cnaz7jdFtBbv7nZ2dnZfqn_WdnZ2d@giganews.com> Lines: 799 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-4OQk/4dMD0KdGEARw4Rd9DD0+DrU0YT3R0GKsvZyOjsJe4V1SVidcuBvvAm6DT7b2WFThYO98l5v114!0p3J8JqQE5WMDeJnC5UOpqt1eP2Xd888zyBqJPkYkIcB4hho0gDstpbY948+5W9acGsZA72NaRXB X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 Bytes: 36489 On 04/20/2024 11:24 AM, Ross Finlayson wrote: > > > Well I've been thinking about the re-routine as a model of cooperative > multithreading, > then thinking about the flow-machine of protocols > > NNTP > IMAP <-> NNTP > HTTP <-> IMAP <-> NNTP > > Both IMAP and NNTP are session-oriented on the connection, while, > HTTP, in terms of session, has various approaches in terms of HTTP 1.1 > and connections, and the session ID shared client/server. > > > The re-routine idea is this, that each kind of method, is memoizable, > and, it memoizes, by object identity as the key, for the method, all > its callers, how this is like so. > > interface Reroutine1 { > > Result1 rr1(String a1) { > > Result2 r2 = reroutine2.rr2(a1); > > Result3 r3 = reroutine3.rr3(r2); > > return result(r2, r3); > } > > } > > > The idea is that the executor, when it's submitted a reroutine, > when it runs the re-routine, in a thread, then it puts in a ThreadLocal, > the re-routine, so that when a re-routine it calls, returns null as it > starts an asynchronous computation for the input, then when > it completes, it submits to the executor the re-routine again. > > Then rr1 runs through again, retrieving r2 which is memoized, > invokes rr3, which throws, after queuing to memoize and > resubmit rr1, when that calls back to resubmit r1, then rr1 > routines, signaling the original invoker. > > Then it seems each re-routine basically has an instance part > and a memoized part, and that it's to flush the memo > after it finishes, in terms of memoizing the inputs. > > > Result 1 rr(String a1) { > // if a1 is in the memo, return for it > // else queue for it and carry on > > } > > > What is a re-routine? > > It's a pattern for cooperative multithreading. > > It's sort of a functional approach to functions and flow. > > It has a declarative syntax in the language with usual > flow-of-control. > > So, it's cooperative multithreading so it yields? > > No, it just quits, and expects to be called back. > > So, if it quits, how does it complete? > > The entry point to re-routine provides a callback. > > Re-routines only return results to other re-routines, > It's the default callback. Otherwise they just callback. > > So, it just quits? > > If a re-routine gets called with a null, it throws. > > If a re-routine gets a null, it just continues. > > If a re-routine completes, it callbacks. > > So, can a re-routine call any regular code? > > Yeah, there are some issues, though. > > So, it's got callbacks everywhere? > > Well, it's just got callbacks implicitly everywhere. > > So, how does it work? > > Well, you build a re-routine with an input and a callback, > you call it, then when it completes, it calls the callback. > > Then, re-routines call other re-routines with the argument, > and the callback's in a ThreadLocal, and the re-routine memoizes > all of its return values according to the object identity of the > inputs, > then when a re-routine completes, it calls again with another > ThreadLocal > indicating to delete the memos, following the exact same > flow-of-control > only deleting the memos going along, until it results all the memos in > the re-routines for the interned or ref-counted input are deleted, > then the state of the re-routine is de-allocated. > > So, it's sort of like a monad and all in pure and idempotent functions? > > Yeah, it's sort of like a monad and all in pure and idempotent > functions. > > So, it's a model of cooperative multithreading, though with no yield, > and callbacks implicitly everywhere? > > Yeah, it's sort of figured that a called re-routine always has a > callback in the ThreadLocal, because the runtime has pre-emptive > multithreading anyways, that the thread runs through its re-routines in > their normal declarative flow-of-control with exception handling, and > whatever re-routines or other pure monadic idempotent functions it > calls, throw when they get null inputs. > > Also it sort of doesn't have primitive types, Strings must always > be interned, all objects must have a distinct identity w.r.t. ==, and > null is never an argument or return value. > > So, what does it look like? > > interface Reroutine1 { > > Result1 rr1(String a1) { > > Result2 r2 = reroutine2.rr2(a1); > > Result3 r3 = reroutine3.rr3(r2); > > return result(r2, r3); > } > > } > > So, I expect that to return "result(r2, r3)". > > Well, that's synchronous, and maybe blocking, the idea is that it > calls rr2, gets a1, and rr2 constructs with the callback of rr1 and it's > own callback, and a1, and makes a memo for a1, and invokes whatever is > its implementation, and returns null, then rr1 continues and invokes rr3 > with r2, which is null, so that throws a NullPointerException, and rr1 > quits. > > So, ..., that's cooperative multithreading? > > Well you see what happens is that rr2 invoked another re-routine or > end routine, and at some point it will get called back, and that will > happen over and over again until rr2 has an r2, then rr2 will memoize ========== REMAINDER OF ARTICLE TRUNCATED ==========