A fault-tolerant prgram in Ring: Easy.

34 views
Skip to first unread message

Mansour Ayouni

unread,
Jul 4, 2024, 10:27:59 AMJul 4
to The Ring Programming Language
Hello All,

I have always sought ways to create fault-tolerant programs for my customers' critical applications. Achieving this has always been a tedious task, regardless of the programming language I used.

However, with Ring's capability of embedding Ring within Ring, this process becomes straightforward and enjoyable.

To illustrate this, I created a program that runs four different codes, each in its own instance of the Ring VM. When an error occurs in one instance, the next code is executed seamlessly, without interruption, as demonstrated in the output window!


image.png

I have included the code in the joined file so you can test it yourself.

NOTE: This advanced feature of Ring has many interesting use cases worth exploring, such as:

  • Implementing retry-and-recovery mechanisms in concurrent applications
  • Simulating parallel execution of heavy operations
  • Adding a plugin system to an application
  • Adding scriptable agents to video games
  • Using automated and configurable testing agents in large codebases

and many more.

@Mahmoud: BRAVO! for this great feature!

Best,
Mansour

ring-fault-tolerance.txt

Mahmoud Fayed

unread,
Jul 4, 2024, 11:03:12 AMJul 4
to The Ring Programming Language
Hello Mansour

Thanks for your kind words :D

The original motivation behind this feature was the ability to run Ring code on Mobile without using another process
Also, later it's used in Try Ring Online: Try Ring Online (ring-lang.github.io)

Greetings,
Mahmoud 

Ilir Liburn

unread,
Jul 4, 2024, 11:30:35 AMJul 4
to The Ring Programming Language
Hello Mansour,

ring_state_runcode used in that way produces memory leak because ring_state is never freed. For the demonstration purposes is OK, but some note about this is highly recommended.

@Mahmoud, can this be solved by using the managed pointer?

Greetings,
Ilir

Mahmoud Fayed

unread,
Jul 4, 2024, 11:42:55 AMJul 4
to The Ring Programming Language
Hello Ilir

>> "@Mahmoud, can this be solved by using the managed pointer?"

Yes, that's why we have managed pointers
Added to my To-Do list

Greetings,
Mahmoud 

Mansour Ayouni

unread,
Jul 4, 2024, 11:47:33 AMJul 4
to msfcl...@gmail.com, ring...@googlegroups.com

Hello ilir,

We can maybe avoid memory leak by deleting each instance created after it has been executed...

Is that a solution to the problem?

Best,
Mansour


--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ring-lang/6837eade-72b3-4253-a9c9-dd61e10f714fn%40googlegroups.com.

Ilir Liburn

unread,
Jul 4, 2024, 11:59:38 AMJul 4
to The Ring Programming Language
Hello Mansour,

Yes, it is a solution to problem. However, when Ring extension is used, extension can detect if pointer is not assigned yet, and then free allocated memory behind the pointer after execution.  This part is missing in built-in Ring function like ring_state_execute because it operates in a different way.

Greetings,
Ilir

Mahmoud Fayed

unread,
Jul 4, 2024, 12:04:40 PMJul 4
to The Ring Programming Language
Hello Ilir

>> "@Mahmoud, can this be solved by using the managed pointer?"

After revising this issue, Now I remember why I don't use a managed pointer in these functions


Using manual management (ring_state_new/init and ring_state_delete) would be more general/simple in this situation.

Greetings,
Mahmoud

On Thursday, July 4, 2024 at 6:30:35 PM UTC+3 ilir...@gmail.com wrote:

Mansour Ayouni

unread,
Jul 4, 2024, 3:49:14 PMJul 4
to msfcl...@gmail.com, ring...@googlegroups.com

Hello Ilir,

Thank you Ilir.

All the best.
Mansour


--

---
You received this message because you are subscribed to the Google Groups "The Ring Programming Language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ring-lang+...@googlegroups.com.

Ilir Liburn

unread,
Jul 4, 2024, 6:31:44 PMJul 4
to The Ring Programming Language
Hello Mansour,

You're Welcome.

Greetings,
Ilir
Reply all
Reply to author
Forward
0 new messages