You have already stated that copying takes too long.
And you can't pass a reference or pointer to it without letting the
original thread wait.
So at first glance the problem is insoluble.
Maybe. I am hoping for some boost or C++ standard mechanism, which I haven't heard of yet, that solves this problem that I presume many developers have run across, when dealing with a function that takes a variable argument list parameter.
Just post real code instead of a vague and most likely incorrect
description.
I think you are reading to much into it and want to look at the design for a fix. I don't blame you. I already accept that the design is flawed, the code sucks, and I'd never use a variable argument list in the first place. Such is often life when dealing with other people's real life code and manager's rules and time allotments vs academic examples. Given those constants,it doesn't matter what the context is, but here:
// Creates a database log record
// \param sprintf like message string including placeholders
// \param ... - takes tuples
// 1- string; name of argument
// 2- string; formatting code string
// 3- any type; identified by previous formatting code
// <list of 500 formatting codes and argument types>
void SomeFunction(std::wstring message, ...) // Cannot change
{
va_list va; // May change anything here down
va_start(va, x);
SomeDataStructure myOutput; // Contains arguments for a database call
// to create a log record
// which is also crappy design
// with tons of params
// and encoded, formatted, strings
// 4000 lines of parsing custom format codes and arguments,
// converting to types
// using those types to build strings
// ala sprintf
// With a dump truck of business rules applied to string encoding
// AKA long and tedious stuff that I want to do on another thread
// Including actually making a call to write to database which is
// also time consuming
//
// i.e. This is a logging type method and should return immediatly
va_end(va);
}
The actual conversion from unknown types into usuable typed objects using format codes in strings is what is taking a long time. I really don't think I mentioned copying as you say. There is no copying yet. I envision copyingas a means to pass them to another thread. As obviously I can't give something to another thread from the stack without blocking the first thread or they will no longer be valid.
The problem itself is how to copy something of unknown type and length fromthe "stack pointer?" given by va_list, without actually processing the list to find the types first.
performance analysis revealed that the processing of the list, just to extract the types and use them to build the output to make the database call with, took longer than the database call itself!