gdsl-general
[Top][All Lists]
Advanced

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

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


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

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

Subject: Generic Data Structure Library problem
Date: Sat, 29 Jun 2002 22:09:33 +0200
From: Hynek Hanke <address@hidden>
To: address@hidden

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.

However, while working on Speech Deamon
(www.freebsoft.org, beta.freebsoft.org) today,
I found a problem I couldn't solve. I believe
it should be implemented in GDSL or that it's
even a bug in it.

To understand why I need this function (which
I will describe later), imagine that I have
a queue of messages from different clients.
Each message is a structure with socket number
as one of the members. One thread of my program
puts these messages in the queue. Other thread
pops messages from queue and sends them to output
modules for speech synthesis. Imagine some client
sends me `pause' command. Now I don't want to
proceed messages from this client. It means that
when I do some queue_get, I don't want to get
messages that have the particular socket_number
in the structure.

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.

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
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.

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 quite in hurry before LSM, every little help
is welcomed.)

Thank you very much for advice
        and even more for GDSL itself!

Hynek Hanke
Czech Republic

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

-- 
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]