Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Contexts AThread?
#1
Just a quickie.. Indy 10.6.3.3..

Is there a way to access the AThread of TIdContext?

I've been unable to find it..

Thanks

JC
Reply
#2
(10-26-2024, 09:01 PM)Justin Case Wrote: Just a quickie.. Indy 10.6.3.3..

FYI, the current version is 10.6.3.6 (soon 10.6.3.7).

(10-26-2024, 09:01 PM)Justin Case Wrote: Is there a way to access the AThread of TIdContext?

Yes. You can typecast the TIdContext.Yarn property to TIdYarnOfThread (from the IdSchedulerOfThread unit). It has a public Thread property.

Reply
#3
Ah yes, what is this Yarn thing btw? - v9 and 8 never had it!
Reply
#4
(10-27-2024, 08:24 PM)Justin Case Wrote: what is this Yarn thing btw? - v9 and 8 never had it!

Yes, it was something new added in v10. The idea was to separate tasks from threads, so a task could be handled across multiple threads, and a thread could handle multiple tasks. The Yarn is what helped link them together.

In reality, that didn't work out so well (see the abandoned SuperCore package, which tried to introduce fiber support). So, things are still 1 task per thread. Although, there is a thread pool in v10, so a thread can handle multiple tasks at least, just not in parallel.

Reply
#5
Hang about..

So a thread could handle multiple tasks (whatever a task is meant to be lol) and a task could be handled across multiple threads..

A context could be passed between multiple threads and multiple threads could pass around a context..

but a thread pool has threads that can handle multiple tasks.. even though multiple tasks cannot be be run on multiple threads... lol.

I'm sure someone could come up with a better tongue twister than me..
Reply
#6
(10-27-2024, 09:35 PM)Justin Case Wrote: So a thread could handle multiple tasks (whatever a task is meant to be lol)


In this case, a task is a client context (TIdContext derives from TIdTask). But the API was abstracted so in theory it could be used for other purposes.

(10-27-2024, 09:35 PM)Justin Case Wrote: and a task could be handled across multiple threads. A context could be passed between multiple threads and multiple threads could pass around a context.


That was the plan, but it never materialized that way.

(10-27-2024, 09:35 PM)Justin Case Wrote: but a thread pool has threads that can handle multiple tasks.

Yes. When a thread is done with a task, the thread can go back in the pool until a new task is ready for it.

That being said, the pooling is not the default behavior. You have to use the TIdSchedulerOfThreadPool component to get the behavior.

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)