• Welcome to Theos PowerBasic Museum 2017.

What is com as super udt?

Started by Paul Breen, July 27, 2009, 02:47:28 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Paul Breen

I have read discussions at an inferior forum that the new com can be used as a super udt. I don't see the advantage, at least at this stage of
my knowledge. What can a com object do for you as a udt that a regular udt can't?. I do not mean methods, of course, because
udt's do not have code, just a data structure.
thanks,
PB

José Roca

 
Well, some guys are unhappy because UDTs doesn't support arrays of dynamic strings and are trying to use classes to workaround it.

Edwin Knoppert

I have this big app(dll) which has a few type variables having asciiz ptr's for texts.
About everthing is accessed as pointer and very confusing (the type is referred as pointer and the contents as well like: @MyType.@psztext).
I made some problematic code for duplicating such variables and if i don't pay attention i forget to clear the asciiz ptr's and have two references to the same memory.
This can crash of course.
I wished we had objects at that time and was forced to prepare good serializing to create duplicates.

Pointers where good for that moment but now i prefer strong typed syntax.
Replacing it all for one objptr reference would not be so bad and the rest of the code would be strong typed and thus will bring less bugs.

Of course, the problem would also be less if dynamic strings were allowed, i don't mind not having this feature at all now.
I am sure at the end you'll benefit more using an object then using an UDT with dynamic strings.

Theo Gottwald

#3
Yes the new Objects can be used as "Super UDT's".
And what is it good for?

Have you ever dreamed of giving and receiving a Parcel of Parameters to a Thread-Function?

Here is it ... Objects and Threads

Paul Breen

Hello Theo:
Your article is informative but also confusing. My pentium 4 machine supports multi-threading but has only one processor. If I run a multi-thread program that obviously used only one core in the pentium 4 machine and put it in a duo-core machine, will the threads automatically run in parallel? Since all work is done by the (one) processor, is there any point in making multi-thread programs if you KNOW that the program will not ever be loaded into a multi-core computer?
  I understand that by synchronizing threads you can prevent one thread from 'blocking' the progress of another thread, but if there is only one processor, is not the overhead of thread synchronizing going to make the total time of processing longer than if the threads just waited their turn?
  How do you know when it is appropriate to utilize multi-threading? Is this technique just for server type software or is it appropriate for desktop applications? I will be processing large quantities of text in the future for a natural language processing project but no one is waiting for the data but me. Will it benefit me to utilize multi-threading?

 

Theo Gottwald

QuoteIf I run a multi-thread program that obviously used only one core in the pentium 4 machine and put it in a duo-core machine, will the threads automatically run in parallel?
Yes. And depending on how the execution Units in the Programm are used, you will even get a benefit on a SMT (Multithreading) CPU.

QuoteSince all work is done by the (one) processor, is there any point in making multi-thread programs if you KNOW that the program will not ever be loaded into a multi-core computer?
If your programm will never be loaded into a multi-core computer, Splitting things into threads may be a waste of time. Unless there are algo-reasons.

Think of a company and a Thread as a employee-workers. Is your Job possibly best done by one person step-ny-step?
Or can it be shared amongst several persons?
Can your Job be done from several Persons at the same time or are there important parts dependend on the outcome of the things to be done before?

QuoteI understand that by synchronizing threads you can prevent one thread from 'blocking' the progress of another thread, but if there is only one processor, is not the overhead of thread synchronizing going to make the total time of processing longer than if the threads just waited their turn?

Assume your Job is to make a stamp on a Letter. Now you get one employee to lift the stamp, and then he has to gie the stamp to a second emplyee to put it on the letter. Does that make sense? If you just let it do one person it will be done faster.

A second thing is, if you have 1000 Stamps to be put on letters. Now each of the employees can put stamps on letters not knowing what the other person is doing. These are the sort of Jobs which love to be multithreaded.

QuoteHow do you know when it is appropriate to utilize multi-threading?
Anything that can be done from many workers at the same time. Stupid repetitional Jobs best, intelligent calculations least.

QuoteWill it benefit me to utilize multi-threading?

Get your your own company and try it!
Employ five people and find out if they can help you doing your Job - while you do something else.
Even if you company won't be an success, you'll have a better understanding of Multithreading and synchronisatiion after all.