4 ms·
About concurrency : does anyone know of a language that would let you tag portions of a codebase in some way, and declare something like "all those methods shou
by bsaul 9y ago
About concurrency : does anyone know of a language that would let you tag portions of a codebase in some way, and declare something like "all those methods should execute in the same thread". Those declarations would then be checked by the compiler.
That would be a first step toward agent like concurrency, but it would be general enough to apply to other types of concurrency models.
- BinaryIdiot 9y agoThat's an interesting concept. Would you also suggest having a way of saying "this method should execute in another thread" or "all of those methods should execute in another thread"?
- bsaul 9y agoI'm still in the process of figuring how that would work. But mostly it would look something like annotation @threading("BACKGROUND_WORK_QUEUE_A") func someWork(data) {} @threading("BACKGROUND_WORK_QUEUE_A") func someSubWork(data) {} @threading("MAIN_QUEUE") func requestHandler() {} and you wouldn't be able to directly call someWork() from requestHandler() directly, but calling someSubWork() from someWork() would be fine. The idea is that i've observed that my code could often be split into parts running in their own threads, and the complex thread splitting code would be at the junction. Adding annotation like that would help me make sure that a function designed to run inside some part wouldn't accidentaly be called directly from another part.
- cmoscoso 9y agoSomething like Agents in Clojure?
- whowouldathunk 9y agoUgh, makes me think of COM https://msdn.microsoft.com/en-us/library/windows/desktop/ms680112(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/ms6...
- int_19h 9y agoThis is different. COM apartments were a runtime mechanism to magically make the code to run on a single thread (or on multiple but specific threads for MTA), by introducing object proxies that "transparently" marshaled calls.
- comex 9y agoYou can do it in C++, actually, using Clang’s thread safety attributes: https://clang.llvm.org/docs/ThreadSafetyAnalysis.html https://clang.llvm.org/docs/ThreadSafetyAnalysis.html You can create a dummy ‘lock’ type that just represents being on a certain thread, with corresponding global variables for different named threads.
- tonyg 9y agoReminds me of "multitier" programming, which is more focussed on a client/server split, but otherwise a similar idea. See for example http://hop.inria.fr/home/index.html http://hop.inria.fr/home/index.html and the extensive research literature, perhaps starting from http://queue.acm.org/detail.cfm?id=2330089 http://queue.acm.org/detail.cfm?id=2330089 or https://www-sop.inria.fr/members/Manuel.Serrano/index-6.html https://www-sop.inria.fr/members/Manuel.Serrano/index-6.html