Obviously,FC is the fundamental library of bitshare toolkit. i would like to have an in-depth study, but do not know how/where to start, is there any documentation i can refer to? attached below are some of my questions, appreciated if anyone help to clarify.
1) there is some following code under the data object,what is the purpose? how it work?and when such code will be executed?
FC_REFLECT(..)
2)there are many multiple thread program like below in bitshare toolkit, i don't quit understand how it work.
my->....complete = fc::async( [=](){ my->process..(); } );
3)Serialization is also frequently used in the toolkit,what data format are the following functions convert to? and where are the data saved after the serialization?any difference of the data format between the following serialization functions
fc::raw::pack( ...);
pub.serialize();
I am reviewing the code for the community and can shed some light on these questions based upon my observations.
Obviously,FC is the fundamental library of bitshare toolkit. i would like to have an in-depth study, but do not know how/where to start, is there any documentation i can refer to? attached below are some of my questions, appreciated if anyone help to clarify.
1) there is some following code under the data object,what is the purpose? how it work?and when such code will be executed?
FC_REFLECT(..)
FC_REFLECT is a macro that expands into a template specialization that calls a method for each member. It seems to enable the creation of different kinds of serialization techniques. The two primary uses seems to be for what he calls 'raw' and 'json'. raw appears to be just a binary representation and json is self explanatory.
2)there are many multiple thread program like below in bitshare toolkit, i don't quit understand how it work.
my->....complete = fc::async( [=](){ my->process..(); } );
This code is actually cooperative multi-tasking and the fc library provides a scheduler that will manage the execution of multiple fibers in a single thread. This is a very useful construct because you do not have to worry about context switching at arbitrary points like you do with multi-threading. On the other hand if a fiber blocks without yielding the other tasks in the same thread will not get executed. fc::async() dispatches a task to be run on the current thread the next time it yields.