gdsl-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gdsl-general] Fwd: Re: Generic Data Structure Library problem


From: Nicolas Darnis
Subject: [gdsl-general] Fwd: Re: Generic Data Structure Library problem
Date: Tue, 2 Jul 2002 17:49:36 +0200

----------  Message transmis  ----------

Subject: Re: Generic Data Structure Library problem
Date: Mon, 1 Jul 2002 11:24:16 +0200
From: Nicolas Darnis <address@hidden>
To: Hynek Hanke <address@hidden>

Hi Hynek (again),

Le Samedi 29 Juin 2002 22:09, vous avez écrit :
> Hi Nicolas,
>
> I'm using your GDSL for two of
> free software packages I'm working on.
> It's a great piece of software. It
> really saves work compared to the
> classical glibc data structure manipulating
> functions.

Thank you for this appreciation.
It will be apreciable in general if you could send your messages
on the gdsl-general mailing list.

> [...]
>
> I tried to write something as
>   message = gdsl_queue_search(queue, compare_function, NULL);
> where the compare function returns
> 1 for messages from clients that are
> `paused', 0 when it's ok. This way,
> I can get the messages I want, BUT ...
> gdsl_queue_search doesn't remove the
> message from queue so I get it every
> time I'm looking. I believe this shouldn't
> be (IMHO, it's not how queues work) -- or
> there should at least be some option.

In fact, the search function is ONLY to be informed
if a particular element is in the queue, not to remove
it. As a queue is a FIFO data structure, there is no
need to add more functions than put() and get().
Put() always put an element at the tail of the queue
and get() always remove the head element.

So, I have a question: why do you want to remove
elements of the queue for which its socket number
correspond to the client that have putted PAUSE
message in the queue? Isn't it possible to put a flag
for this client in your reader thread to ignore the future
messages sent by your particular client until this one
sent a CONTINUE message? Why precisely you want
to remove the messages after PAUSE ones instead of
ignoring them? Maybe it's more difficult to implement
or it implies more job?

> To sum up my problem: I have some queue
> and sometimes need to extract elements that
> are not at the head, but I can identify them

Then, I suggest you to use another data structure
like gdsl_list because of the properties of a queue
(see above put() and get()).

> by some (*compare_function)(). I need to remove
> them from the queue after getting them. I've
> been thinking about other ways to do the
> job (eg. use another data structure or use
> multiple queues one for each client), but
> this way seems to be the best.

Yes you're right, the good way to do what you want:
uses a gdsl_list data structure and use it as
a queue. gdsl_list module provide function to remove
particular elements like gdsl_list_remove_by_value()
that is exactly what you want.

> Please, is there any simple way how to solve
> this problem? I think gdsl_queue_search should
> remove the element. Or even gdsl_queue_remove_by_value
> would be fine.

I'm not agree with four first affirmation: search functions
doesn't modifiy the data structure.

> (I'm quite in hurry before LSM, every little help
> is welcomed.)

This is my conclusion:

please, tell me if its a problem for you to use gdsl_list module
instead of gdsl_queue. Tell me wy if its a problem for you. Then
I will decide or not to add gdsl_queue_remove_by_value() function
even if I think it should not be possible to do this in a queue data
structure.

Again, thank you for your mail, and be sure I will answer and help
you to solve your problem as quick as you answered to this mail.

Finaly, please consider subscribing to the gdsl mailing list again ;-)
Then the messages will have could be interesting for other people.
Some people ask me about gdsl and only them have the answers.
That's not very usefull for the other one. The other advantage, is
that the mailing lists are archived so it's easier for me to find
 informations I've already answered by reading the archives.

Thak you for your interest in GDSL.

Yours,
--
Nicolas Darnis
mailto:address@hidden
work phone: (+33) 05 56 01 98 34
GPG 0x6B794D9E:         051F 3035 0183 A6DD 2701 A773 EE05 821E 6B79 4D9E

-------------------------------------------------------

-- 
Nicolas Darnis
mailto:address@hidden
work phone: (+33) 05 56 01 98 34
GPG 0x6B794D9E:         051F 3035 0183 A6DD 2701 A773 EE05 821E 6B79 4D9E



reply via email to

[Prev in Thread] Current Thread [Next in Thread]