Tag cftimeout

Description

Add tag cftimeout to Lucee

Activity

Michael Offner 
29 August 2022 at 13:36
(edited)

First of all in Lucee the name attribute of the tag thread is not required, for action run, it never was, as you suggested Lucee does create a name for the thread if no defined.

Yes Lucee does create a new thread in the back for this, but it is still not the same. With cfthread the code in the body get executed in a new thread with different scope, lifecyle, …. With cftimeout the code get executed in the same thread, the thread open just is a controler thread. with cftimeout it is the other way around, the main thread is the controller thread.

your example is also invalid, i must look more like this

In addition the tag comes with attributes that provide functionality not possible with cfthread

  • onTimeout:function - listener for timeout, if not set an exception is thrown in case of a timeout, if set that function is called with the necessary data, it is up to the function to throw an exception or not

  • onError:function - listener for an exception, if not set an exception an exception inside the body of the tag is simply throw, if set that function is called with the necessary data, it is up to the function to throw an exception or not

  • forcestop:boolean - if set to true and a a timeout occurs that get catch by the listener “onTimeout“, this flag decides if Lucee simply let the code inside the body go on parallel or does stop the code execution.

BTW there are many constructs in the language you could argue that thy are not necessary because you can achive the goal in a different way as well.

For example a “for“ loop is not necessary, you can do everything you can do with “for“ also with a “while”, even “if“ is not necessary or “switch“ and don’t get me started with all the “unnecessary” “each“ functions.

was asking for that tag for a very long time and my answer was for a very long time the same, simply use cfthread, but he insisted, so I implemented it in a way that gives you additional features you not can easily to with cfthread so it’s existence makes sense.

I already had long discussions about “static“ in Lucee, some love it, same hate it and some ignore it. If you don’t like that feature, then hate it, ignore it or both .

Brad Wood 
15 July 2022 at 16:37

I’ve thought about this in the past, but I never put in a ticket, because honestly, how is it any different than this:

In fact, I’d assume the cftimeout tag will actually just use a thread in the background anyway. How about we simply remove the requirement of a name on the thread tag (use a generic name as a default) and then we’re done?

Michael Offner 
15 July 2022 at 16:26

Fixed

Details

Assignee

Reporter

Labels

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Sprint

Fix versions

Priority

Created 15 July 2022 at 16:05
Updated 15 June 2023 at 08:28
Resolved 29 August 2022 at 13:41