mulle-objc / mulle-objc-developer

🎩 mulle-objc developer kit for mulle-sde
BSD 3-Clause "New" or "Revised" License
13 stars 1 forks source link

Concurrent Actor Model #4

Open PythonLinks opened 6 years ago

PythonLinks commented 6 years ago

I want to build a real time server. Actually a tree of chat servers organized by topic. You can see the related lightening talk at blog.pythonlinks.info. Erlang has the right concurrency model, but the language is not object-oriented.
Python has a great object language but only a single thread at a time.
Go is statically bound. Which brought me back to my beloved Objective-C. 
But what to do about concurrency? I found the answer right here. https://www.ios-blog.com/tutorials/objective-c/asynchronous-message-passing-with-actors-in-objective-c/

Basically every concurrent actor is a subclass of Thread. You send a message to the actor, it goes into their input queue. It gets copied and processed. No problem with locks. A very simple computational model. But the repository is not very active because with Apple’s Objective-C you have to create a new class for every message. With Mulle-objc, the messages is itself a data structure, so easy to write a function which copies any message.

Anyhow I am new to all of this concurrency stuff. Am I on the right track? Is anyone else thinking along these lines? Is this the killer application for Mulle-objc?

Warm Regards
 Christopher Lozinski PythonLinks.info

mulle-nat commented 6 years ago

Actors are interesting, but I only have knowledge about them by having watched some Youtube videos :) I think the main difference between ObjC messages and Actor messages are, that Actor messages are one-way only (async), whereas ObjC is call and return (sync). So it looks more like an event model. I think for a distributed chat server this would be interesting to use, but I am out of my level of expertise there.

PythonLinks commented 6 years ago

Thank you. Very good point. Messages to a thread would have to not return a value.