1

Topic: with a principal flow.

After architecture reorganization on a real multithreading began to come up many bugs, here today at last it turned out to localize the main.
There is any action in one of flows, it is necessary to notify a principal flow (that any actions in a principal flow to fulfill, in a window something to make etc.) on it
Now it goes through a call, well here for example:

procedure TBaseCharacter. AddToSystemJournal (Value: String);
...Here we do everything that is necessary, including we create object SystemJournalData, and in the end -
if CurrentThread. ThreadID <> MainThreadID then
Queue (procedure begin EventOnSystemJournalAdded (Self, Value, SystemJournalData); end)
else
EventOnSystemJournalAdded (Self, Value, SystemJournalData);

It is logical that while it in a principal flow from queue gets yes will be fulfilled (flows can be much, and under some conditions, for example simultaneous connection - they will throw simultaneously in queue on synchronization a heap of calls) - Value already can be easily changed or  is destroyed (EDoubleFreeError from Eureka - my favourite error).
Changed all Queue on Synchronize - a problem did not solve generally, only hardly it became more difficult to play back.
and different it is a lot of everyones, parameters all different. Simultaneously in queue two can rush identical  so to do class variables too not a variant.
At me any unhealthy imaginations about class linked lists with  for each parameter, and so on already begin.
Prompt, how this all business is correct is resolved?

2

Re: with a principal flow.

Or, as a variant, everywhere before adding in queue to create pointers of the same types, as variables, and in the main flow at performance - to release them.
But something it is not pleasant to me, here so even to unwinding I will not tell than.

3

Re: with a principal flow.

Vizit0r wrote:

procedure TBaseCharacter. AddToSystemJournal (Value: String);

Problems of architecture with such piece of the code to consider difficult.
I will simply tell just in case: begin with const value.
Then all the same try to do a local copy that actually will be more true.

4

Re: with a principal flow.

wadman wrote:

it is passed...
Problems of architecture with such piece of the code to consider difficult.
I will simply tell just in case: begin with const value.
Then all the same try to do a local copy that actually will be more true.

And what exactly from the code is necessary to you? I will lay out, not a question.
The local copy is in local variable? So in a case with Queue by the time of performance in  - procedure that actually caused Queue already will be completed, together with all local variables.
const value - what for if in output agents value does not change?

5

Re: with a principal flow.

Vizit0r;
With implicit objects not simply, especially if at you not ARC a control model storage. As a universal remedy it is possible to implement explicit event queue in a primary window then flows in it will add the events (through critical sections) and to send the message that queue changed, and the principal flow will assort it...

6

Re: with a principal flow.

Vizit0r wrote:

the local copy is in local variable?

In storage. LocalAlloc, LocalFree.

7

Re: with a principal flow.

wadman wrote:

it is passed...
In storage. LocalAlloc, LocalFree.

It is pure  - does not approach.

Zelius wrote:

Vizit0r;
With implicit objects not simply, especially if at you not ARC a control model storage. As a universal remedy it is possible to implement explicit event queue in a primary window then flows in it will add the events (through critical sections) and to send the message that queue changed, and the principal flow will assort it...

I already approach to it. Especially, it gives the chance group handling and other.

8

Re: with a principal flow.

Vizit0r wrote:

it is pure  - does not approach.

With such requests...
GetMem, FreeMem?

9

Re: with a principal flow.

Vizit0r wrote:

the local copy is in local variable? So in a case with Queue by the time of performance in  - procedure that actually caused Queue already will be completed, together with all local variables.

Procedure - comes to an end
Local variables - come to an end
And here other variables in which there will be copies of value of those local, do not come to an end, at them own lifetime
Approximately as queues work in OmniThreadLibrary
Supposed there value - and let to itself goes to the addressee how many it is necessary
And the addressee already then let cleans storage, if it is necessary

10

Re: with a principal flow.

wadman;
And and will be - New, Dispose.