Here's a link that helped me out when I needed to find out what javascript function is bound to each ribbon button.

Basically, the steps you have to follow are (applies to sp2010, the might be slight differences in sp2013):


Find the id attribute of the ribbon button. eg. Ribbon.EditingTools.CPEditTab.Markup.Html.Menu.Html.EditSource-Menu16. Next go to 14 hive and under TEMPLATE\GLOBAL\XML\ find cmdui.xml file. This file contains definition for all ribbon buttons in SharePoint. Search in this file by word Ribbon.EditingTools.CPEditTab.Markup.Html.Menu.Html.EditSource
Consider the Command attribute (which, in the example, is equals to EditSource)
search this command among SharePoint javascript files. Common architecture of ribbon handler involves javascript "classes" which can handle particular command. Each class has canHandleCommand method. Search under 14\layouts using pattern *.js by word (in the example, “EditSource”). Find handleCommand method in the class and take note of the line number.
in browser find this line and set a breakpoint, then you can step into to find the exact code that will be called (in the example, RTE.RichTextEditor.editSource() ). This is the handler 


Ribbon javascript function reference
In my code I save data in a binary file, when I save I run the function save() in a different thread. The data that I'm saving are stored in a vector&lt;uint_32&gt;, this vector is used also by others function and I did a  copy to avoid conflicts and not desired modification, I think that this isn't the most efficient way to solve this problem so I want ask which is the best way to have this kind of behavior? I was thinking about shared pointers, maybe. 
here is the code:

inline void write( std::vector&lt;uint32_t &gt; pData ) {
    fThread = std::thread( &amp;FileHandler::writeFile, this, pData );
    fThread.join();
}
inline void writeFile( std::vector&lt;uint32_t&gt;  cVectorCopy ) {
    fwrite( ( char* )&amp;cVectorCopy[0]  , cVectorCopy.size()*sizeof( uint32_t ) , 1, fBinaryFile );
    closeFile();
}

