Posts

c - Producer/Consumer using TCP client/server -

the server intended multithreaded server spawns new threads upon either producer or consumer connection via tcp. problem i'm getting stuck in wait state once producer client fills queue. snippet shows server's handling of producer connection. format of request producer sends put (item) reqline[0] = strtok (mesg, " \t\n"); if ( strncmp(reqline[0], "put\0", 4)==0 ) { item[0]=strtok(null," \t\n"); pthread_create (&pro, null, producer, fifo); pthread_join (pro, null); } so can see i'm creating new thread handles job of filling queue/detecting when empty. code within producer: queue *fifo; int i=atoi(item[0]); char*fullmsg="full\n"; fifo = (queue *)q; pthread_mutex_lock (fifo->mut); while (fifo->full) { //the problem block printf ("producer: queue full.\n"); send(conn_s, fullmsg,st...

c++ - using gprof and boost -

while profiling bit of code use's many boost functions gprof, there nasty , hard follow output see sample below , there way clean gprof use boost or more boost friendly alternatives? looks of there repition of boost::math::policy cluttering profiling output making difficult see or understand call graph btw heres snippet of example boost::math::policies::policy<boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy, boost::math::policies::default_policy> >(long double, long double, long double*, long double*, int, boost::math::policies::policy<boost::math::po...

objective c - Mocking KVO with OCMock -

i test key-value-observation working class of mine. has 1 property, depends on another. set so: + (nsset *)keypathsforvaluesaffectingsecondproperty { return [nsset setwithobjects: @"firstproperty", nil]; } - (nsarray *)secondproperty { return [self.firstproperty array]; } i want run unit test verify when firstproperty changes, object bound secondproperty gets notification. @ first thought able use +[ocmockobject observermock] , looks can used nsnotificationcenter . best way test this? i worked on while after @chrispix's answer inspired me work in different direction. started this: id objecttoobserve = [[theclassbeingtested alloc] init]; id secondpropertyobserver = [ocmockobject mockforclass:[nsobject class]]; [[secondpropertyobserver expect] observevalueforkeypath:@"secondproperty" ofobject:objecttoobserve change:...

git - How do you see which commit deleted a file from the repo? -

this question has answer here: find when file deleted in git 4 answers since no longer in repository, can't do git log <filename> i can run git log --diff-filter='d|r' <directory_that_contained_it> but information , grepping not seem list file i'm looking for. git log -1 --stat -- <path/to/file> i put --stat in there can verify file deleted.

Call intent to make a call with put extra to select a phone number in Android? -

i trying create way user can contact friend via sms, email , phone call. have completed email , sms part. have figured out how use createchooser select how message sent using either email or text message, achieved clicking on button, following code how this: intent = new intent(intent.action_send); i.settype("text/plain"); i.putextra(intent.extra_email , new string[]{""}); i.putextra(intent.extra_subject, "check out awesome score!"); i.putextra(intent.extra_text , "i playing awesome game called tap button, , scored incredible highscore of " +s+ " taps!!\n\ncan beat it!?"); try { startactivity(intent.createchooser(i, "send mail...")); } catch (android.content.activitynotfoundexception ex) { toast.maketext(fail.this, "there no email clients installed.", toast.length_short)....

In VB6, is it possible to call a function with an operator in the parameter? -

i'm having hard time finding answer this, such generic terminology, , it's possible question still difficult parse. have code variable representing amount of free disk space remaining percentage. want call function, use reverse amount in message user, i.e. amount of used space. can little math in function call? public sub myapp() dim nfreespace integer nfreespace = getfreespace displayusedspace 100 - nfreespace 'is valid? end sub private function displayusedspace(byval nusedspace integer) boolean msgbox("you have used " & nusedspace & "% of disk drive space.") end function yes, valid. although, write this call displayusedspace(100 - nfreespace) but, code work fine too.

c++ - How to compile Boost.Log standalone -

after doing research, partially on stack overflow, decided try boost.log library andrey semashev. unfortunately, build boost.log library i have place in boost source tree , compile part of boost. blocker me, because have complicated building configuration. i want build boost.log standalone. i've found interesting thread on boost.log forum , method doesn't work me. instead of using boost.log, might suggest consider cpplog: https://github.com/andrew-d/cpplog it's header library based on google's logging library.