Re: bpc_send semantics and per-channel application-specific data?
"William J. Mills" <[email protected]> Fri, 10 Oct 2003 13:21:56 -0700
| Newsgroups | gmane.network.beep.beepcore.c.general |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Oct 10, 2003 at 11:50:50AM -0700, Darren New wrote:
> David C Niemi wrote:
> > I noticed that buffers are generally copied before calling bpc_send().
> > Why is this necessary, and are there circumstances under which it may be
> > omitted?
>
> The core part of the protocol doesn't copy the data around. You ask the
> core for a frame to store the data in, and the core sends directly from
> that memory space until it's done. That was the original code, and I
> haven't looked for a while, and it's possible the higher-level code
> copies the data into an allocated frame instead of letting you allocate
> your own, tho. But minimizing copies was one of the (annoying ;-)
> requirements for the core code.
>
> William would have to tell you whether the threaded layer copies the data.
>
Hmmm... don't remember. I think perhaps we do in some cases since we are
not sure the profile code won't free the data before it's sent, but if you
are using an allocated frame it should do the right thing.
> > I also need to keep some information that is per-channel and per-message
> > that is application-specific. Is there any preexisting clean place to put
> > such things, or do I need to make and maintain my own data structures for
> > both?
>
> I don't think there's any such place in the core for doing that, since
> the core manages its own structures internally. If there were a pointer
> to data, there would have to be a pointer to the clean-up routine.
> Actually, I kind of remember doing something like that, but I don't
> remember if it was for internal or external data. But it should be
> pretty obvious whether it's in the core data structures or not. They're
> not that complicated. :-)
>
>
lemme just drop in the appropraite header file section here... bp_wrapper.h
You hafta maintain the data yourself, but you can associate it with the
channel.
/*
* Accessor function to allow the application or profile to retrieve an
* arbitrary pointer stored in the channel instace.
*
* @param inst A pointer to the channel-instance structure.
*
* @return The most recent pointer passed to
* {@link bpc_set_channel_info bpc_set_channel_info} for this channel.
**/
extern void* bpc_get_channel_info(struct CHANNEL_INSTANCE *inst);
/*
* Accessor function to allow the application or profile to store an
* arbitrary pointer with the channel instace.
*
* @param inst A pointer to the channel-instance structure.
*
* @param data An arbitrary pointer provided by the application.
**/
extern void bpc_set_channel_info(struct CHANNEL_INSTANCE *inst,
void *data);
-bill
-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php