Each() deprecated


I found this page today about Lucee & threads: Threads :: Lucee Documentation

I was reading the first blog article about Parallelism on Lucee that uses the each() function.

Viewing the docs I see it is deprecated.

Is the reason for that because we should be using the other types of each statements like array.each, query.each, etc?

On a separate note. Does the admin screen Services → Tasks → Maximum Concurrent Threads setting have to do with the threads that would be created with the each() functions with parallel = true?

I think in part yes. But cfml has lots of iterating iterating functions: We have these functions for the various datatypes, plus we have also new functional programming functions (.map(),.reduce()), plus we can use for(item in array) and the legacy for/next and cfloop. That are a wide range of alternatives and we can use what fits best. Besides of that each() is soley a Lucee cfml function that hasn’t been adopted by ACF.

1 Like

Re: “Services → Tasks → Maximum Concurrent Threads” question, I would suspect this has more to do with Lucee’s specialized CFThread. By default, CFThread spawns a thread in the context of the current application. But, you can add [type = "task"] to the CFThread tag and Lucee will write the thread to disk as a file and then execute outside of the application context. My guess is that the thing you’re talking about is to determine how many of those task threads can be run in parallel?

But, I’m just shooting from the hip here.

1 Like

Hi Ben,

I was thinking the other day that if I had multiple pages running that used each() or one of the alternatives, there would be a setting that would prevent too many tasks from running at a time and overwhelming the server.

But from what I gather, I would use cfthread type=task and then the setting in the admin area, and they would be queued if the maximum concurrent threads are already running.

If that is how it works, I do see how that would be much better than having scheduled tasks.

@randy-johnson to be clear, I don’t really have a great understanding of the low-level implications of running a lot of threads. I will say that I am cautious about it; but, I’ll also say that I don’t think I’ve ever seen it cause an issues (that I’ve been made aware of).