Hi fellow CP-ers. I worked with monstrous legacy C/C++ code where the GUI and business logic components are executed in the same thread. It worked fine, but the GUI is similar to Win 3.1 style: ugly clunky and yucky (sorry for hardcore 3.1-ers!). Since then we upgraded our system with new GUI tools and processors. We decided to take this opportunity to untangle the system. We put all the biz logic in one thread (this hosts multiple apps, drawing or non-drawing), and all related GUI items (rendering loop, animations, and all its support classes) on the other thread. IMO, this is very beneficial since for example the button may animate fade in or out, etc, while the biz logic thread can still host other non-drawing applications. Note that we will try to do as much as we can locally in rendering thread if it doesn't involve biz logic (ex: highlights, international strings, etc). If it requires data, it will post to biz logic thread and retrieve it. So this new guy came in and decided to put all the GUI classes back to the business logic thread. Rendering is still done on other thread, but now for every single little graphics primitives (think set colors, move obj to x,y, set transparency, etc) we need to send out a message. His reasoning is that it's too clumsy to post handler messages to other thread, he prefers call back, and he said it's common for most GUI frameworks to have this synchronous behavior. Can someone help me explain why the synchronicity of button handler is so important? Am I missing something? Don't we already have similar model of biz logic / presentation separation in present day web technology? (i.e. Fancy flash animations in your web browser sending/fetching data from the server, or AJAX heavily used by Google apps?)
crewchill
Posts
-
Separating business and presentation logic in different threads -
Memory allocation in multi-threaded applicationI think he meant which code calls the heap allocator? Try IBM Rational Purify. They have 30-day license I believe. It should keep track of allocations and deallocations, leaks, etc, complete with the stack of the callers.
-
Non-template based common data structure?Hi folks, I'm looking for non-template based library that provides common data structures (queue, vector, etc). The non-template part is crucial since I'm doing embedded system and I need the code to be portable to older EC++ compilers. Ideas? Commercial or non-commercial suggestions accepted! Thanks in advance!
-
const void as return typeAmen to Friday. My head is about to explode already. You know the scariest part was, this is quite recent code. The older version didn't have this and somehow the extra "const" appeared after it's being code reviewed :( Not by me, mind you.
-
const void as return typeHm... which gcc are you using? Mine doesn't even complain about it.
~
$ cat x.c
#include <stdio.h>typedef const void (*hello)();
const void x()
{
printf("x() is called\n");
}int main()
{
hello test=x;
test();
}~
$ gcc x.c~
$ ./a.exe
x() is called~
$ gcc --ver
Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
Configured with: /usr/build/package/orig/test.respin/gcc-3.4.4-3/configure --ver
bose --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libe
xecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-langu
ages=c,ada,c++,d,f77,pascal,java,objc --enable-nls --without-included-gettext --
enable-version-specific-runtime-libs --without-x --enable-libgcj --disable-java-
awt --with-system-zlib --enable-interpreter --disable-libgcj-debug --enable-thre
ads=posix --enable-java-gc=boehm --disable-win32-registry --enable-sjlj-exceptio
ns --enable-hash-synchronization --enable-libstdcxx-debug
Thread model: posix
gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125) -
const void as return typeI found this code a little confusing. Due to proprietary nature of the original source, I have to abstract this out. What does const void return value mean? I can understand the intent of "const void*" return value, but "const void" seems to be just a typo? Am I missing anything fancy with the construct here?
#include typedef const void (*hello)();
const void x()
{
printf("x() is called\n");
}int main()
{
hello test=x;
test();
} -
Folding doxygen comments with Eclipse CDT?Thanks for your reply! The slash star and slash slash exclamation is out of the question due to company's coding standard. What I don't understand is why the triple slashes when it's tabbed inside it won't fold? I don't think the Eclipse CDT team haven't noticed that format already...
-
Folding doxygen comments with Eclipse CDT?Hi. I've been googling this for a while now, and I still find no good answer for it. Before you throw RTFM at me, I'm still searching for the answer. But if you've been through this before, any useful links are appreciated. This would fold nicely:
// xyz
// @param x
// @param yThis would fold nicely also:
/*
* xyz
* @param x
* @param y
*/This wouldn't fold:
/// xyz
/// @param x
/// @param yThis wouldn't fold either:
// xyz // @param x // @param y
It won't kill me to see these, but as the code grows it's getting harder and harder to see the function names.
-
Eclipse CDT and implicit makefilesHi. I'm running into this vexing problem with using Eclipse IDE to load existing makefiles. The problem is the makefiles are defined by implicit rules. For example, the include path has a variable $(INCLUDE) that is being set and modified depending on other included makefiles (.mk). So now Eclipse would just barf the flag "Unresolved inclusion". I can fix this by reading the makefile which the source directory belong to, and add the path manually. Doing this individually for 55 directories really suck. Any ideas how to make this work? Maybe a tool to run all the makefiles once and update the .cproject file maybe? Or, is there other C++ IDE that takes in Cygwin GCC compiler and GDB that can handle this (I tried NetBeans with C++, same problem) ? Doesn't have to be free. Thanks!
-
"extern inline" in C header fileI searched the forum for this specific question and can't find it so here it is. I ran into this "extern inline" syntax in several U-boot C header files. I know the idea about putting extern is to avoid the multiple definition, but the confusing part is the inline part. What happens in my compiler is this... it takes the extern, but not the inline. So during linking, it's looking for that function, and can't find it. Now I normally use inline keyword for C++ header files that is protected by include guard, so the extern is not really useful (especially inlined functions already have definition there). My question is, can someone explain in layman's term how this "extern inline" supposed to work? They seem to be mutually exclusive to me: "extern" keyword means "it's defined somewhere else" and inline means "replace your code with this definition". So I believe my compiler is behaving correctly... Yes, I know I can google into this, but I'm just too lazy to think now :laugh: Thanks!
-
What's the best way to do conditional compile?It's not nested if... it's nested #if. And the reason they have to do #if, is that in certain platform the function or even the structure protected inside the #if is not available (not compiled).
-
What's the best way to do conditional compile?I hate posting this, since probably 85% of general population actually love using #if and #ifdef and even see that's the only easy way to do "cross-platform". I don't, BTW. Here is my gripe. One #if is fine. Nested #if is nasty (I've seen #if else nested 8 level deep, with structures whose definition has more #if in it). Problem is #if begets another #if. I work in a company that has at least 90 conditional compile flags set into either makefile or command line. BTW, my Unix terminal has to scroll 4 pages for the complete build commands (and yes, mostly are the -D define flag). The worst part is the flags are peppered all over the code, maybe 2 millions LOC. And nobody bothers to consolidate them. I've seen a Linux distro that has parts of files that is different between platform stored in different directory. I couldn't remember what the Linux flavor was. They choose between target sources in makefile, instead of in the code. And the differences are stored in different dirs for ex. /x86 /alpha /risc, and these files have exactly same files with different content. I think this is a much more cleaner and maintainable approach. The key is to identify what would be different and consolidate it in one area. Any other ideas?
-
Multi-word coding convention.Trying to decide between Parser::parseHtmlTag or Parser::parseTagHtml parseHtmlTag sounds like natural English, but when we have more than 1 kind of parse, it becomes: Parser::parseHtmlTag Parser::parseBodyTag Parser::parseATag So far so good, but if we have Parser::parseSomethingElse, it's a little hard to group / sort them based on "Tag". Parser::parseCssElement Parser::parseRandomElement I made the last 2 up :) But you get the general idea. It's hard to group them, is it tag or element. My boss already dissed the idea of passing parameter to parseTag() saying it's not explicit enough what the method is doing. I love to hear your preference on this and the reason. I don't really care, I just want to know how people usually code it. And, yes I do have a life :) !!!
-
Debugging DLL loaded with LoadLibraryYes they are. Thinking a little bit more about it, I dont know if this matters, but these DLLs are being copied to another directory instead of being used straight from their respective Debug directory. So instead being run from "MyProj\Debug\MyProj.dll" there is a post-build step to "copy MyProj\Debug\MyProj.dll c:\output\dlls". Thus the code loads the Dll like LoadLibrary("c:\output\dlls\MyProj.dll")
-
Debugging DLL loaded with LoadLibraryAll right, I give up. There must be a trick to this. Basically I have this gigantic workspace with projects that spits out little DLLs. Some of the basic DLLs are loaded by another DLL which is finally loaded by the executable file. What happens when I put a breakpoint is that the Visual Studio spits out warning the breakpoint is disabled. I already put in all the DLLs under the "additional DLL" under Debug tab in MS VC 6.0, and still no luck. Any help is appreciated!! :confused: Frank
-
Animated GIFHi all. I need some help understanding the Animated GIF rendering. If you have implemented the Animated GIF, you probably notice there are "disposal method" and transparency support. The disposal method values can be "return to previous state", "fill with background", or "do not dispose". Now my question is, suppose I have a canvas (ready to be bitblt), and frame A has "do not dispose" disposal method. So I put frame A on the canvas, fine. No big deal. Then frame B has a smaller size (along with top and left field) picture with a transparent color. Should I be checking on frame B if it's transparent color then do not put that pixel on the canvas? This checking takes a long time, especially on a cell phone. So I wonder if I can bypass it all together. Any ideas? Thanks, -- Frank
-
regsvr32Hi. I was using Inside COM by Dale Rogerson book and I dont have the CD, so I kinda guess how to register the component. But when I do "regsvr32 /s Cmpnt.dll" , the entry for "InprocServer32" is garbage. Can someone help me out with this? Registry.cpp: #include extern "C" HRESULT RegisterServer(HMODULE g_hModule, const CLSID& CLSID_Component1, const char* g_szFriendlyName, const char* g_szVerIndProgID, const char* g_szProgID) { CComModule cm; return cm.RegisterClassHelper(CLSID_Component1, g_szProgID, g_szVerIndProgID, NULL, THREADFLAGS_BOTH); } cmpnt.def: ; ; Cmpnt1 module-definiteion file ; LIBRARY Cmpnt.dll DESCRIPTION '(c)1996-1997 Dale E. Rogerson' EXPORTS DllCanUnloadNow @1 PRIVATE DllGetClassObject @2 PRIVATE DllRegisterServer @3 PRIVATE DllUnregisterServer @4 PRIVATE DllMain @5 PRIVATE
-
VS_VERSION_INFO questionIt is. Yes you can rename it. It seems like Windows OS doesnt care much about filename as long as it already acquired the handle for exe. Done this a few times. And you are right if it is not the file that is running, it works fine. I just hard code the exe filename because my project is called version.dsp. Just for a test program. I guess this rename - copy - check version idea doesnt work. :(( Thanks!
-
VS_VERSION_INFO questionBOOL CVersionDlg::OnInitDialog() { ......... regular MFC exe wizard ....... SetTimer(1, 5000, NULL); return TRUE; // return TRUE unless you set the focus to a control } void CVersionDlg::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default CString strFile = "E:\\MyProjects\\version\\Debug\\version.exe"; DWORD size = GetFileVersionInfoSize(strFile.LockBuffer(),0); strFile.UnlockBuffer(); if(size > 0) { CString results; char *pData = new char[size]; // GET THE FILE VERSION AND STORE IT IN pData if(GetFileVersionInfo(strFile.LockBuffer(), 0, size, pData)) { strFile.UnlockBuffer(); VS_FIXEDFILEINFO* lpvi; UINT iLen; if(VerQueryValue(pData,"\\", (void **)&lpvi, &iLen)) { // FORMAT THE VERSION EXAMPLE ( 1.2.3.1 ).. results.Format("%u.%u.%u.%u",HIWORD(lpvi->dwFileVersionMS),LOWORD(lpvi->dwFileVersionMS), HIWORD(lpvi->dwFileVersionLS),LOWORD(lpvi->dwFileVersionLS)); MessageBox("Version", results); } } delete[] pData; } CDialog::OnTimer(nIDEvent); } Make 2 version.exe, put one with version 1.0.0.1 (version1.exe) and the other one 1.0.0.5 (version5.exe). Copy version1.exe to version.exe. Run version.exe. A dialog should pop up 1.0.0.1 every 5 seconds. Rename version.exe to version.bak. The dialog should cease popping up. Copy version5.exe to version.exe. The dialog will pop up again still with 10.0.0.1 (while it should be 10.0.0.5). So still no solution :confused:
-
VS_VERSION_INFO questionMy question is how to use GetVersionInfo() to return the correct value. Thanks