Search Results

Search found 3592 results on 144 pages for 'pointer'.

Page 98/144 | < Previous Page | 94 95 96 97 98 99 100 101 102 103 104 105  | Next Page >

  • Marshalling a C structure to C#

    - by Hilbert
    Hi, I don't know how to marshall this structure in Mono. typedef struct rib_struct { rib_used_t used; rib_status_t status; rib_role_t role; uint8_t conf; rib_dc_t *pending; pthread_mutex_t mutex; pthread_cond_t cond; rib_f_t *props; } rib_t; And for example, rib_dc_t is like: typedef struct rib_dc_struct { uint16_t id; uint8_t min_id; uint8_t conf; struct rib_dc_struct *next; } rib_dc_t; I don't know how to marshall the pthread structures. And the pointers... should I use IntPtr or a managed structures? How to mashall the pointer in the last struct to the struct itself? Thanks in adanvaced

    Read the article

  • Trouble creating a makefile

    - by catia
    Hi everyone! I'm having some trouble making a Makefile. Write now I just compile everything every time. Although, the professor is ok with that, I do want to get it working faster and to avoid unnecessary compiling. Here's what I have. FILES= p6.cpp SetIter.cpp Node.cpp Set.cpp CFLAGS= -ansi -pendantic -Wall -Wextra CC= g++ MakePg6: p6.cpp SetIter.cpp Node.cpp Set.cpp $(CC) $(CFLAGS) $(FILES) -o pg6 Node.cpp - node class Set.cpp - uses nodes. Friend of Node. SetIter.cpp - gets a set and uses a pointer to iterator through I'm confused with some of the depencies arising from the friends thing and the point of lib.o being included in the Makefile as some sites have. Any help is greatly appreciated. Thanks in advance.

    Read the article

  • delete & new in c++

    - by singh
    Hi This may be very simple question,But please help me. i wanted to know what exactly happens when i call new & delete , For example in below code char * ptr=new char [10]; delete [] ptr; call to new returns me memory address. Does it allocate exact 10 bytes on heap, Where information about size is stored.When i call delete on same pointer,i see in debugger that there are a lot of byte get changed before and after the 10 Bytes. Is there any header for each new which contain information about number of byte allocated by new. Thanks a lot

    Read the article

  • Send copy of class to view class so it can render him? ( iPhone )

    - by Johannes Jensen
    I'm making a game for the iPhone, and I have a class called Robot. Then I have a class called View, which renders everything. I want to send a copy of my Robot, which I defined in my ViewController, and I send it to gameView (which is View *gameView), like this: robot = [Robot new]; [gameView setRobot: [robot copy]]; I tried to make a copy but that didn't work, I could also do it with a pointer to Robot (&robot) but sometimes it just crashes ? I tried this in my View.h @interface definition: @property (copy) Robot* robot; but I get the error /RobotsAdventure/Classes/View.h:24: error: setter '-robot' argument type does not match property type :/ Help? I'm pretty new at this, heh.

    Read the article

  • small string optimization for vector?

    - by BuschnicK
    I know several (all?) STL implementations implement a "small string" optimization where instead of storing the usual 3 pointers for begin, end and capacity a string will store the actual character data in the memory used for the pointers if sizeof(characters) <= sizeof(pointers). I am in a situation where I have lots of small vectors with an element size <= sizeof(pointer). I cannot use fixed size arrays, since the vectors need to be able to resize dynamically and may potentially grow quite large. However, the median (not mean) size of the vectors will only be 4-12 bytes. So a "small string" optimization adapted to vectors would be quite useful to me. Does such a thing exist? I'm thinking about rolling my own by simply brute force converting a vector to a string, i.e. providing a vector interface to a string. Good idea?

    Read the article

  • Help for CSS Menu Dropdown, FF OK and IE6 Problem

    - by Taruhku
    IE Problem, FF OK. Please help..???? Screen Shoot problem click here This is my CSS dolphincontainer { position:relative; height:56px; color:#E0E0E0; background:#143D55; width:100%; font-family:Tahoma; left: 0px; } dolphinnav {position:absolute;;height:33px;font-size:12px;font-weight:bold;background:#fff url(images/dolphin_bg.gif) repeat-x bottom left;padding:0 0 0 10px;width:975px;} dolphinnav ul {margin:0;padding:0;list-style-type:none;width:auto;float:left;} dolphinnav ul li {display:block;float:left;margin:0 1px;} dolphinnav ul li a {display:block;float:left;color:#001b2c;text-decoration:none;padding:0 0 0 10px;height:33px;} dolphinnav ul li a span {padding:12px 20px 0 0;height:21px;float:left;font-weight:bold;} dolphinnav ul li a:hover {color:#fff;background:transparent url(images/dolphin_bg-OVER.gif) repeat-x bottom left;} dolphinnav ul li a:hover span {display:block;width:auto;cursor:pointer;} dolphinnav ul li a.current,#dolphinnav ul li a.current:hover {color:#fff;background:#00517e url(images/dolphin_left-ON.gif) no-repeat top left;line-height:275%;} dolphinnav ul li a.current span {display:block;padding:0 20px 0 0;width:auto;background:#00517e url(images/dolphin_right-ON.gif) no-repeat top right;height:33px;} .tuckUp { display:block; width:90px; height:30px; overflow:hidden; cursor:pointer; } .pullDown { width:90px; height:56px; } .item a:link, .item a:visited { display:inline; float:left; background:#fff url(images/dolphin_bg.gif) repeat-x top left;padding:0 0 0 10px; text-align:left; color:#444; font-size:11px; font-weight:bold; text-decoration:none; line-height:25px; margin:0 5px 0px 0px; width:80px; } .item a:hover { display:inline; float:left; background:#39c; color:#FFF; text-decoration:none; text-align:left; font-size:11px; font-weight:700; font-weight:bold; line-height:25px; padding:0 0 0 10px; margin:0 5px 0px 0px; width:80px; } HTML: <div id="dolphincontainer"> <div id="dolphinnav"> <ul> <li><a href="index.php"><span>Home</span></a></li> <li><a href="chooseus.php"><span>Why Choose Us</span></a></li> <li><a href="peraturan.php"><span>Rules</span></a></li> <li class="tuckUp" onmousemove="this.className='pullDown'" onmouseout="this.className='tuckUp'"><a href="#"><span>Transaction</span></a> <div class="item"> <a href="drop1.php">Drop Down 1</a><br /> <a href="drop2.php">Drop Down 2</a></a><br /> <a href="drop3.php">Drop Down 3</a><br /> </div> </li> <li><a href="download.php"><span>Download</span></a></li> <li><a href="aboutus.php"><span>About Us</span></a></li> <li><a href="help.php" class="current"><span>Support</span></a></li> <li><a href="promo.php"><span><font color="#FF0000"><blink>PROMO</blink> </font></span></a></li> </ul> </div> </div>

    Read the article

  • Avoiding Nested Blocks

    - by Helium3
    If there is a view controller that wants to execute a number of block based tasks one at a time, how can the control be given back to the view controller after a completion block has executed. Lets say ViewControllerOne wants to execute a number of tasks, each relying on the result of the previous one, how would this control be given back to the viewcontroller after each completion block has been executed? I started thinking about this and I was heading towards a deeply nested block pattern that will surely only cause confusion to whoever else reads or tests it. A task executes and the completion block returns the result or error which is needed by the next task, which has its own completion task, that the next task relies on and so forth. How can the control be managed in one place, the viewcontroller? Would the completion block just call the next function that handles the next task, using a pointer to the view controller?

    Read the article

  • Are self-described / auto-descriptive services loosely or tightly coupled in a SOA architecture ?

    - by snowflake
    I consider a self-described / auto-descriptive service as a good thing in a SOA architecture, since (almost) everything you know to call the service is present in the service contract (such a WSDL). Sample of a non self-described service for me is Facebook Query Language (FQL http://wiki.developers.facebook.com/index.php/FQL), or any web service exchanging XML flow in a one String parameter for then parsing XML and performing treatments. Last ones seem further more technically decoupled, since technically you can switch implementations without technical impact on the caller, handling compatibility between implementations/versions at a business level. On the other side, having no strong interface (diluted into the service and its version), make the service tightly coupled to the existing implementation (more difficulty to interchange the service and to ensure perfect compatibility). This question is related to http://stackoverflow.com/questions/2503071/how-to-implement-loose-coupling-with-a-soa-architecture So, are self-described / auto-descriptive services loosely or tightly coupled in a SOA architecture ? What are the impacts regarding ESBs ? Any pointer will be appreciated.

    Read the article

  • Designing an API with compile-time option to remove first parameter to most functions and use a glob

    - by tomlogic
    I'm trying to design a portable API in ANSI C89/ISO C90 to access a wireless networking device on a serial interface. The library will have multiple network layers, and various versions need to run on embedded devices as small as an 8-bit micro with 32K of code and 2K of data, on up to embedded devices with a megabyte or more of code and data. In most cases, the target processor will have a single network interface and I'll want to use a single global structure with all state information for that device. I don't want to pass a pointer to that structure through the network layers. In a few cases (e.g., device with more resources that needs to live on two networks) I will interface to multiple devices, each with their own global state, and will need to pass a pointer to that state (or an index to a state array) through the layers. I came up with two possible solutions, but neither one is particularly pretty. Keep in mind that the full driver will potentially be 20,000 lines or more, cover multiple files, and contain hundreds of functions. The first solution requires a macro that discards the first parameter for every function that needs to access the global state: // network.h typedef struct dev_t { int var; long othervar; char name[20]; } dev_t; #ifdef IF_MULTI #define foo_function( x, a, b, c) _foo_function( x, a, b, c) #define bar_function( x) _bar_function( x) #else extern dev_t DEV; #define IFACE (&DEV) #define foo_function( x, a, b, c) _foo_function( a, b, c) #define bar_function( x) _bar_function( ) #endif int bar_function( dev_t *IFACE); int foo_function( dev_t *IFACE, int a, long b, char *c); // network.c #ifndef IF_MULTI dev_t DEV; #endif int bar_function( dev_t *IFACE) { memset( IFACE, 0, sizeof *IFACE); return 0; } int foo_function( dev_t *IFACE, int a, long b, char *c) { bar_function( IFACE); IFACE->var = a; IFACE->othervar = b; strcpy( IFACE->name, c); return 0; } The second solution defines macros to use in the function declarations: // network.h typedef struct dev_t { int var; long othervar; char name[20]; } dev_t; #ifdef IF_MULTI #define DEV_PARAM_ONLY dev_t *IFACE #define DEV_PARAM DEV_PARAM_ONLY, #else extern dev_t DEV; #define IFACE (&DEV) #define DEV_PARAM_ONLY void #define DEV_PARAM #endif int bar_function( DEV_PARAM_ONLY); // I don't like the missing comma between DEV_PARAM and arg2... int foo_function( DEV_PARAM int a, long b, char *c); // network.c #ifndef IF_MULTI dev_t DEV; #endif int bar_function( DEV_PARAM_ONLY) { memset( IFACE, 0, sizeof *IFACE); return 0; } int foo_function( DEV_PARAM int a, long b, char *c) { bar_function( IFACE); IFACE->var = a; IFACE->othervar = b; strcpy( IFACE->name, c); return 0; } The C code to access either method remains the same: // multi.c - example of multiple interfaces #define IF_MULTI #include "network.h" dev_t if0, if1; int main() { foo_function( &if0, -1, 3.1415926, "public"); foo_function( &if1, 42, 3.1415926, "private"); return 0; } // single.c - example of a single interface #include "network.h" int main() { foo_function( 11, 1.0, "network"); return 0; } Is there a cleaner method that I haven't figured out? I lean toward the second since it should be easier to maintain, and it's clearer that there's some macro magic in the parameters to the function. Also, the first method requires prefixing the function names with "_" when I want to use them as function pointers. I really do want to remove the parameter in the "single interface" case to eliminate unnecessary code to push the parameter onto the stack, and to allow the function to access the first "real" parameter in a register instead of loading it from the stack. And, if at all possible, I don't want to have to maintain two separate codebases. Thoughts? Ideas? Examples of something similar in existing code? (Note that using C++ isn't an option, since some of the planned targets don't have a C++ compiler available.)

    Read the article

  • How to convert from integer to unsigned char in C, given integers larger than 256?

    - by Alf_InPogform
    As part of my CS course I've been given some functions to use. One of these functions takes a pointer to unsigned chars to write some data to a file (I have to use this function, so I can't just make my own purpose built function that works differently BTW). I need to write an array of integers whose values can be up to 4095 using this function (that only takes unsigned chars). However am I right in thinking that an unsigned char can only have a max value of 256 because it is 1 byte long? I therefore need to use 4 unsigned chars for every integer? But casting doesn't seem to work with larger values for the integer. Does anyone have any idea how best to convert an array of integers to unsigned chars?

    Read the article

  • Dynamic binary from file

    - by Aurel300
    This is a little bit of weird problem here. Say I have a C++ code, running on a specific platform. The only purpose of this code is to run files containing binary, NATIVE to that platform. Now - my question is - HOW would I get the data from these files (could even be by bits, like 1024 bits a cycle) to the memory of machine running my code so that this data would be in the execution part? In other words, can I get the data to somewhere where I can point the instruction pointer? If yes, how? I don't mind if I have to use assembler for this - just so it would work.

    Read the article

  • Unable to get Processor Speed in Device

    - by mukesh
    Hi i am using QueryperformanceFrequency to get the No of cycle i.e processor speed. But it is showing me the wornd value. It is written in the specicfication is the Processor is about 400MHz, but what we aregetting through code is something 16MHz. Please porvide any pointer : The code for Wince device is: enter code here LARGE_INTEGER FrequnecyCounter; QueryPerformanceFrequency(&FrequnecyCounter); CString temp; temp.Format(L"%lld",FrequnecyCounter.QuadPart)`AfxMessageBox(temp); Thanks, Mukesh

    Read the article

  • What will be the setup process for website development?

    - by Vijay Shanker
    Hi, I want to create a simple site for my personal usage. And this only in python based technologies. So I want to get a expert oponian on this topic. What should i used as platform? I did a search for available options and found Django, grok, web2py and many more of these. Which one a novice use should use? If I choose to use only the basic python scripts then what option i have to work on? http://wiki.python.org/moin/WebBrowserProgramming. This link on python site confused me more, instead of solving my curiosity about the topic. Please give some pointer to accurate and easy to understand reading materials. I have got a idea of developing java based web applications using either spring-webmvc and struts. Can I relate Java process to python process for web development?

    Read the article

  • C++'s unordered_map / hash_map / Google's dense_hash - how to input binary data (buf+len) and insert

    - by shlomif
    Hi all, I have two questions about Google's dense_hash_map, which can be used instead of the more standard unordered_map or hash_map: How do I use an arbitrary binary data memory segment as a key: I want a buffer+length pair, which may still contain some NUL (\0) characters. I can see how I use a NUL-terminated char * string , but that's not what I want. How do I implement an operation where I look if a key exists, and if not - insert it and if it does return the pointer to the existing key and let me know what actually happened. I'd appreciate it if anyone can shed any light on this subject. Regards, -- Shlomi Fish

    Read the article

  • one document.createElement, append it twice, only shows once

    - by Sirber
    I have a button I want to use in the beginning and the end of the page: var button_save = document.createElement('button'); $("#compteurs").append(button_save); [...] $("#compteurs").append(button_save); but it only appear at the end of the page. If I remove it from the bottom of the page, it appear at the begining of page. It's a kind of pointer. Is there a way to create the button only once and use it twice? Thanks!

    Read the article

  • Cannot implicitly convert type 'char*' to 'bool'

    - by neeraj
    i was trying to passing pointer value in the function , i really got stuck here I am a beginner , not getting what value should be put this is programme from the reference of the book "Cracking the coding interview " By Gayle Laakmann McDowell, class Program { unsafe void reverse(char *str) { char* end = str; char tmp; if (str) //Cannot implicitly convert type 'char*' to 'bool' { while(*end) //Cannot implicitly convert type 'char*' to 'bool' { ++end; } --end; while(str<end) { tmp = *str; *str+= *end; *end-= tmp; } } } public static void Main(string[] args) { } }

    Read the article

  • Interrupting `while loop` with keyboard in Cython

    - by linello
    I want to be able to interrupt a long function with cython, using the usual CTRL+C interrupt command. My C++ long function is repeatedly called inside a while loop from Cython code, but I want to be able, during the loop, to send an "interrupt" and block the while loop. The interrupt also should wait the longFunction() to finish, so that no data are lost or kept in unknown status. This is one of my first implementation, which obviously doesn't work: computed=0; print "Computing long function..." while ( computed==0 ): try: computed = self.thisptr.aLongFunction() except (KeyboardInterrupt, SystemExit): computed=1 print '\n! Received keyboard interrupt.\n' break; (p.s. self.thisptr is the pointer to the current class which implements aLongFunction() )

    Read the article

  • Store address dynamic array in c

    - by user280642
    I'm trying to save the address of a dynamic array index. struct sstor *dlist; struct node *q; q->item = &(dlist->item[(dlist->sz)-1]); // Problem? This is my node struct node { char **item; struct node *next; struct node *prev; }; This is my array struct sstor { int sz; int maxsz; char item[][1024]; }; I'm still new to pointers. The line below gives the error: assignment from incompatible pointer type q->item = &(dlist->item[(dlist->sz)-1]);

    Read the article

  • Regular Expression to match unlimited number of options

    - by Pekka
    I want to be able to parse file paths like this one: /var/www/index.(htm|html|php|shtml) into an ordered array: array("htm", "html", "php", "shtml") and then produce a list of alternatives: /var/www/index.htm /var/www/index.html /var/www/index.php /var/www/index.shtml Right now, I have a preg_match statement that can split two alternatives: preg_match_all ("/\(([^)]*)\|([^)]*)\)/", $path_resource, $matches); Could somebody give me a pointer how to extend this to accept an unlimited number of alternatives (at least two)? Just regarding the regular expression, the rest I can deal with. The rule is: The list needs to start with a ( and close with a ) There must be one | in the list (i.e. at least two alternatives) Any other occurrence(s) of ( or ) are to remain untouched.

    Read the article

  • Manage bad_alloc exception in C++ construtor

    - by Jimmy zhang
    I have Java experience and recently am doing some C++ coding. My question is that if I have class A, in which I have to instantiate class B and class C as two of the member variables of A. If in the constructor of A, should I assume that allocations of class B and C never fail, and handle the bad allocation exception in the destructor of A? If I don't make that assumption, meaning that I add some try catch block to catch bad_alloc of class B and class C, then if the allocation exception occurs, should I do clean up in the constructor of A? What are the recommended practices? If "new" generates a bad allocation, what value does the pointer carry?

    Read the article

  • Best way to track impressions/clicks in a bespoke advertisement system?

    - by Martin Bean
    I've been asked to create a bespoke advertisement system despite suggesting open source alternatives such as OpenX and DoubleClick for Publishers (the former Google Ad Manager). I've got the basics of the system set up, i.e. uploading creatives, creating positions and a mechanism to place creatives within positions; however, the area I'm stuck with is impression and click tracking. At the moment an impression and click is stored with the creative, but this then means impressions/clicks can't be queried. For example, we can't find how many impressions were in position x between date y and date z. How would I go about storing that kind of data? My theory was store the creative ID, position ID and timestamp in a database table, but given the amount of traffic the site has this would produce a very large database very quickly. If any one could give me a pointer or two, that would be great.

    Read the article

  • Screen capture code produces black bitmap

    - by wadetandy
    I need to add the ability to take a screenshot of the entire screen, not just the current window. The following code produces a bmp file with the correct dimensions, but the image is completely black. What am I doing wrong? void CaptureScreen(LPCTSTR lpszFilePathName) { BITMAPFILEHEADER bmfHeader; BITMAPINFO *pbminfo; HBITMAP hBmp; FILE *oFile; HDC screen; HDC memDC; int sHeight; int sWidth; LPBYTE pBuff; BITMAP bmp; WORD cClrBits; RECT rcClient; screen = GetDC(0); memDC = CreateCompatibleDC(screen); sHeight = GetDeviceCaps(screen, VERTRES); sWidth = GetDeviceCaps(screen, HORZRES); //GetObject(screen, sizeof(BITMAP), &bmp); hBmp = CreateCompatibleBitmap ( screen, sWidth, sHeight ); // Retrieve the bitmap color format, width, and height. GetObject(hBmp, sizeof(BITMAP), (LPSTR)&bmp) ; // Convert the color format to a count of bits. cClrBits = (WORD)(bmp.bmPlanes * bmp.bmBitsPixel); if (cClrBits == 1) cClrBits = 1; else if (cClrBits bmiHeader.biSize = sizeof(BITMAPINFOHEADER); pbminfo-bmiHeader.biWidth = bmp.bmWidth; pbminfo-bmiHeader.biHeight = bmp.bmHeight; pbminfo-bmiHeader.biPlanes = bmp.bmPlanes; pbminfo-bmiHeader.biBitCount = bmp.bmBitsPixel; if (cClrBits bmiHeader.biClrUsed = (1bmiHeader.biCompression = BI_RGB; // Compute the number of bytes in the array of color // indices and store the result in biSizeImage. // The width must be DWORD aligned unless the bitmap is RLE // compressed. pbminfo-bmiHeader.biSizeImage = ((pbminfo-bmiHeader.biWidth * cClrBits +31) & ~31) /8 * pbminfo-bmiHeader.biHeight; // Set biClrImportant to 0, indicating that all of the // device colors are important. pbminfo-bmiHeader.biClrImportant = 0; CreateBMPFile(lpszFilePathName, pbminfo, hBmp, memDC); } void CreateBMPFile(LPTSTR pszFile, PBITMAPINFO pbi, HBITMAP hBMP, HDC hDC) { HANDLE hf; // file handle BITMAPFILEHEADER hdr; // bitmap file-header PBITMAPINFOHEADER pbih; // bitmap info-header LPBYTE lpBits; // memory pointer DWORD dwTotal; // total count of bytes DWORD cb; // incremental count of bytes BYTE *hp; // byte pointer DWORD dwTmp; int lines; pbih = (PBITMAPINFOHEADER) pbi; lpBits = (LPBYTE) GlobalAlloc(GMEM_FIXED, pbih-biSizeImage); // Retrieve the color table (RGBQUAD array) and the bits // (array of palette indices) from the DIB. lines = GetDIBits(hDC, hBMP, 0, (WORD) pbih-biHeight, lpBits, pbi, DIB_RGB_COLORS); // Create the .BMP file. hf = CreateFile(pszFile, GENERIC_READ | GENERIC_WRITE, (DWORD) 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, (HANDLE) NULL); hdr.bfType = 0x4d42; // 0x42 = "B" 0x4d = "M" // Compute the size of the entire file. hdr.bfSize = (DWORD) (sizeof(BITMAPFILEHEADER) + pbih-biSize + pbih-biClrUsed * sizeof(RGBQUAD) + pbih-biSizeImage); hdr.bfReserved1 = 0; hdr.bfReserved2 = 0; // Compute the offset to the array of color indices. hdr.bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER) + pbih-biSize + pbih-biClrUsed * sizeof (RGBQUAD); // Copy the BITMAPFILEHEADER into the .BMP file. WriteFile(hf, (LPVOID) &hdr, sizeof(BITMAPFILEHEADER), (LPDWORD) &dwTmp, NULL); // Copy the BITMAPINFOHEADER and RGBQUAD array into the file. WriteFile(hf, (LPVOID) pbih, sizeof(BITMAPINFOHEADER) + pbih-biClrUsed * sizeof (RGBQUAD), (LPDWORD) &dwTmp, ( NULL)); // Copy the array of color indices into the .BMP file. dwTotal = cb = pbih-biSizeImage; hp = lpBits; WriteFile(hf, (LPSTR) hp, (int) cb, (LPDWORD) &dwTmp,NULL); // Close the .BMP file. CloseHandle(hf); // Free memory. GlobalFree((HGLOBAL)lpBits); }

    Read the article

  • Please explain syntax rules and scope for "typedef"

    - by unknown google user
    What are the rules? OTOH the simple case seems to imply the new type is the last thing on a line. Like here Uchar is the new type. typedef unsigned char Uchar; But a function pointer is completely different. Here the new type is pFunc: typedef int (*pFunc) (int); I can't think of any other examples offhand but I have come across some very confusing usages. So are there rules or are people just suppose to know from experience that this is how it is done because they have seen it done this way before? ALSO: What is the scope of a typedef. Thanks to everyone.

    Read the article

  • Multithreading with STL container

    - by Steven
    I have an unordered map which stores a pointer of objects. I am not sure whether I am doing the correct thing to maintain the thread safety. typedef std::unordered_map<string, classA*>MAP1; MAP1 map1; pthread_mutex_lock(&mutexA) if(map1.find(id) != map1.end()) { pthread_mutex_unlock(&mutexA); //already exist, not adding items } else { classA* obj1 = new classA; map1[id] = obj1; obj1->obtainMutex(); //Should I create a mutex for each object so that I could obtain mutex when I am going to update fields for obj1? pthread_mutex_unlock(&mutexA); //release mutex for unordered_map so that other threads could access other object obj1->field1 = 1; performOperation(obj1); //takes some time obj1->releaseMutex(); //release mutex after updating obj1 }

    Read the article

  • Compiling C++ when two classes references one another

    - by Omry
    I am trying to write a simple wrapper around a connection pointer that will return it to the pool when the wrapper is destroyed. but it wont compile because the ConnectionPool and AutoConn need each other to be declared. I tried to use forward deceleration but it didn't work. how do I solve this? (using g++) class Connection {}; class ConnectionPool { Connection *m_c; public: AutoConn getConn() { return AutoConn(this, m_c); // by value } void releaseConnection(Connection *c) { } }; class AutoConn { ConnectionPool* m_pool; Connection *m_connection; public: AutoConn(ConnectionPool* pool, Connection *c) : m_pool(pool), m_connection(c) {} ~AutoConn() { m_pool->releaseConnection(m_connection); } };

    Read the article

< Previous Page | 94 95 96 97 98 99 100 101 102 103 104 105  | Next Page >