Home » U++ Library support » U++ Core » [c++11] Problem with executing callback with Vector
Re: [c++11] Problem with executing callback with Vector [message #44707 is a reply to message #44701] |
Sat, 30 May 2015 19:20   |
Zbych
Messages: 327 Registered: July 2009
|
Senior Member |
|
|
mirek wrote on Fri, 29 May 2015 08:32
Passing Vector to callback...
Well, the trouble is you need copy and containers do not have "direct" copy.
Quick fix is IMO to use Callback1< WithDeepCopy< Vector<int> > >.
Another quick fix is to use Value[Array] instead.
If you insist on using Vector directly (both above options come at certain performance penalty), you need to reorganize the code so that you can pass reference or pointer.
Anyway, as long as you want to use PostCallback, I think your example is not correct, as PostCallback accepts simple Callback (no parameters). Perhaps you meant using something like THISBACK1 ?
If so, you could perhaps use lambda to overcome the problem...
Mirek
If you have time, please take a look at ClientHandler::OnProcessMessageReceived from ChromiumBrowser package:
https:// code.google.com/p/upp-mirror/source/browse/trunk/bazaar/Chro miumBrowser/ClientHandler.cpp
This function receives message from V8 rendering process - message name and a vector of values.
I want to convert CefValue to Upp::Value and pass it to GUI thread. The problem is that I don't want to store this vector somewhere and pass a reference since I don't know how long I should keep it. The easiest way is to pass a copy of vector to callback.
But maybe there is some other way. To be honest, I don't know what do you mean by Value[Array].
Regards,
Zbych
|
|
|
Goto Forum:
Current Time: Fri Jul 18 07:20:12 CEST 2025
Total time taken to generate the page: 0.03662 seconds
|