Search Results

Search found 2715 results on 109 pages for 'lazy initialization'.

Page 65/109 | < Previous Page | 61 62 63 64 65 66 67 68 69 70 71 72  | Next Page >

  • What effect does static const have on a namespace member

    - by user144182
    namespace MyNamespace { static const double GasConstant = 1.987; Class MyClass { // constructors, methods, etc. }; }; I previously had GasConstant declared within the MyClass declaration (and had a separate definition in the source file since C++ does not support const initialization of non-integral types). I however need to access it from other files and also logically it seems like it should reside at the namespace level. My questions is, what effect does static const have in this case? Clearly const means I can't assign a new value to GasConstant, but what does a static member at the namespace mean. Is this similar to filescope static effect, where the member is not accessible outside of the unit?

    Read the article

  • initializer_list in the VC10

    - by user335870
    hi i wrote this program in VC++ 2010: class class1 { public: class1 (initializer_list<int> a){}; int foo; float Bar; }; void main() { class1 c = {2,3}; getchar(); } but i get this errors when i compile project: Error 1 error C2552: 'c' : non-aggregates cannot be initialized with initializer list c:\users\pswin\documents\visual studio 2010\projects\test_c++0x\test_c++0x\main.cpp 27 and 2 IntelliSense: initialization with '{...}' is not allowed for object of type "class1" c:\users\pswin\documents\visual studio 2010\projects\test_c++0x\test_c++0x\main.cpp 27 what is the problem?

    Read the article

  • [OpenCV] cvFilter2D works very very slow in Ubuntu 9.10 amd64?

    - by Hong
    Hi, has someone tried the cvFilter2D under 64bit linux? Recently when I was trying to port some code to the amd64 version of Ubuntu 9.10, I just found that the cvFilter2D works really slow. The version is Opencv 2.0. The code is as follows: CvMat *mat_src = cvCreateMat(128, 128, CV_32FC1); CvMat *mat_dest = cvCreateMat(128, 128, CV_32FC1); CvMat* mat_kernel = cvCreateMat( 25, 25, CV_32FC1); // initialization ... cvFilter2D( (CvMat*)mat_src, (CvMat*)mat_dest, (CvMat*)mat_kernel, cvPoint( (25-1)/2, (25-1)/2)); // I needs approximately 100ms to finish that... My CPU is Intel 2.4G However, the Opencv 1.1pre only cost me 3ms for the same code...

    Read the article

  • Problems with delete in destructor

    - by Vera
    Hello, I wrote this code. The constructor works normally, but in the destructor I get "Windows has triggered a breakpoint." How should I correct this? template class CyclicalArray { private: T* mem_ptr; public: CyclicalArray(size_t capacity, const T& default_value) { this->default_value = default_value; this->capacity = capacity; head_index = 0; mem_ptr = ::new T[capacity]; //memory allocating for(T* p = mem_ptr; p < mem_ptr + capacity * sizeof(T); p += sizeof(T)) { ::new (p) T (default_value); //initialization } } ~CyclicalArray() { for(T* p = mem_ptr + sizeof(T); p < mem_ptr + capacity * sizeof(T); p += sizeof(T)) { p->~T(); } delete[] mem_ptr; }

    Read the article

  • Passing an array for setting variable

    - by mathk
    Hi, I often see this idiom when reading php code: public function __construct($config) { if (array_key_exists('options', $config)) { ... } if (array_key_exists('driver_options', $config)) { ... } } Here I am concern with the way the parameter is used. If I were in lisp I would do: (defun ct (&key options driver_options) (do-something-with-option-and-driver_option)) But since I am in PHP I would rather have a constructor that take a list of parameter and let them be null if there a not require. So what do you guys think about having an array as parameter in other to do some initialization-or-whatever? In other to answer you have to take in account the point of view of the user of the function and the designer of the API. Also have you ever heard this has a code-smell? thanks

    Read the article

  • How to make query on a property from a joined table in Hibernate using Criteria

    - by Palo
    Hello, I have the following mapping: <hibernate-mapping package="server.modules.stats.data"> <class name="User" table="user"> <id name="id"> <generator class="native"></generator> </id> <many-to-one name="address" column="addressId" unique="true" lazy="false" /> </class> <class name="Address" table="address"> <id name="id"> <generator class="native"></generator> </id> <property name="street" /> </class> </hibernate-mapping> How can I do a Criteria query to select all users living on some street? That is create Criteria query for this SQL: Select * from user join address on user.addressId = address.id where address.street='someStreet'

    Read the article

  • directx audio video error message in debugmode

    - by clamp
    I have a c#/winforms application that uses directx to play some video and audio. whenever i start my application in debugmode i get this annoying message. i can click "continue" and everything seems to work fine. but i still want to get rid of this message. it does not show up in releasemode. Managed Debugging Assistant 'LoaderLock' has detected a problem in 'C:\pathtoexe.exe'. Additional Information: DLL 'C:\WINDOWS\assembly\GAC\Microsoft.DirectX.AudioVideoPlayback\1.0.2902.0__31bf3856ad364e35\Microsoft.DirectX.AudioVideoPlayback.dll' is attempting managed execution inside OS Loader lock. Do not attempt to run managed code inside a DllMain or image initialization function since doing so can cause the application to hang.

    Read the article

  • Back button causes iFrame to delay window.onLoad event

    - by JoJo
    I serve ads through an iFrame. The ad network's servers are much slower than mine, so I asyncronously load the iFrame after the window.onLoad event. Event.observe( window, 'load', function() { $('ad').writeAttribute('ad.html'); } ); A problem occurs when you enter the site via the browser's back button. Unexpectedly, the ad iFrame attempts to load immediately, delaying window.onLoad for a few seconds. During these few seconds, the site is unusable because I do a bunch of initialization after window.onLoad. As far as I know, this only happens in Firefox. How do I prevent this blocking load?

    Read the article

  • Can we you the attached properties in C# class library?

    - by Manas Agarwal
    Hi I have implemented the Observer Pattern with lazy load. The class that requests the data from the database is a singleton class. Now I am able to load the data from one database (located in one datacenter) very easily. But I need to get the data from other data centers too and display on the same UI. I can somehow pass the address of second data center and fetch the data from there also. But once I will get the data from second data center, it will be added to earlier list only. So later it will be thought for me to distinguish between the data. So I thought of attaching a property with the result set, so that while displaying the output I can show the data for both the data centers separately but on the same UI. I thought of attached property as an option where I can attach the data center name with the list of the data obtained. How is it possible to do in C#? Thanks Manas

    Read the article

  • Hierarchical Hibernate, how many queries are executed?

    - by ghost1
    So I've been dealing with a home brew DB framework that has some seriously flaws, the justification for use being that not using an ORM will save on the number of queries executed. If I'm selecting all possibile records from the top level of a joinable object hierarchy, how many separate calls to the DB will be made when using an ORM (such as Hibernate)? I feel like calling bullshit on this, as joinable entities should be brought down in one query , right? Am I missing something here? note: lazy initialization doesn't matter in this scenario as all records will be used.

    Read the article

  • Autotest notifications on Ubuntu virtual environment

    - by Luciano
    I am having trouble getting Rails autotest notifications to work on the Engine Yard Vagrant environment. On the Mac, I normally get the notifications via Growl. However, on the virtual environment (which runs Ubuntu) that doesn't work. I tried running Linux notification setups such as libnotify+autotest-notification, but I get the following error: libnotify-Message: Unable to get session bus: /bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed. ** (notify-send:1004): CRITICAL **: dbus_g_proxy_connect_signal: assertion `DBUS_IS_G_PROXY (proxy)' failed ** (notify-send:1004): CRITICAL **: dbus_g_proxy_connect_signal: assertion `DBUS_IS_G_PROXY (proxy)' failed ** (notify-send:1004): CRITICAL **: dbus_g_proxy_call: assertion `DBUS_IS_G_PROXY (proxy)' failed Another path would be to have Growl receive the notifications remotely, but I don't even know where to begin with that... Any suggestions?

    Read the article

  • Using Timer only once

    - by zaidwaqi
    Hi, I want to use a timer only once, at 1 second after the initialization of my main form. I thought the following would have a message box saying "Hello World" just once, but actually a new message box says "Hello World" every one second. Why so? I had put t.Stop() in the tick event. Also, do I need to dispose the timer somehow to avoid memory leakage? Timer t = new Timer(); t.Interval = 1000; t.Tick += delegate(System.Object o, System.EventArgs e) { MessageBox.Show("Hello World"); t.Stop(); }; t.Start(); Please help and show if there is a better way of doing this? Thanks.

    Read the article

  • Autofac: Reference from a SingleInstance'd type to a HttpRequestScoped

    - by Michael Wagner
    I've got an application where a shared object needs a reference to a per-request object. Shared: Engine | Per Req: IExtensions() | Request If i try to inject the IExtensions directly into the constructor of Engine, even as Lazy(Of IExtension), I get a "No scope matching [Request] is visible from the scope in which the instance was requested." exception when it tries to instantiate each IExtension. How can I create a HttpRequestScoped instance and then inject it into a shared instance? Would it be considered good practice to set it in the Request's factory (and therefore inject Engine into RequestFactory)?

    Read the article

  • Java DAO caching

    - by santiagobasulto
    I'm developing a medium Java app, and i'm facing a small problem due to my lack of experience. I've a custom DAO, which gets "Article" objects from the Database. I've the Article class, and the DAO has a method called getArticle(int id), this method returns an Article. The Article has a Category object, and I'm using lazy loading. So, when I request for an article's category (Article a = new Article(); a.getCategory();) the Article class gets the Category from the DAO and then returns it. I'm now thinking to cache it, so when I request multiple times to an article's category, the database is only queried one time. My question is: where should I put that cache? I can put it on the Article class (in the DTO), or I can put it on the DAO class. What do you say?

    Read the article

  • Java Archtecture Decision !!

    - by santiagobasulto
    Hi everybody! I'm developing a medium Java app, and i'm facing a small problem due to my lack of expirience. I've a custom DAO, which gets "Article" objects from the DataBase. I've the Article class, and the DAO has a method called getArticle(int id), this method returns an Article. The Article has a Category object, and i'm using lazy loading. So, when i request for an Article Category (Article a = new Article(); a.getCategory();) the Article class gets the Category from the DAO and then returns it. I'm now thinking to cache it, so when i request multiple times to an Article's category, the database is only queried one time. My question is: where should i put that cache? I can put it on the Article class (in the DTO), or i can put it on the DAO class. What do you say? Thanks!

    Read the article

  • Can getAttribute() method of Tomcat ServletContext implementation be called without synchronization?

    - by oo_olo_oo
    I would like to read some parameters during servlet initializtion (in init() method), and store them among servlet context attributes (using getServletContext().setAttribute()). I would like to read these parameters later - during some request processing (using getServletContext().getAttribute()). So, the multiple threads could do this simultaneously. My question is if such an attempt is safe? Could I be sure that multi threaded calls to the getAttribute() don't mess up any internal state of the servlet context? Please take into account that I'm not going to call the setAttribute() anywhere besides the initialization. So, only calls to the getAttribute() are going to be done from multiple threads. But depending on the internal implementation, this also could be dangerous. So, any information about Tomcat's implementation would be appreciated.

    Read the article

  • Is this class + constructor definition pattern overly redundant?

    - by Protector one
    I often come across a pattern similar to this: class Person { public string firstName, lastName; public Person(string firstName, string lastName) { this.firstName = firstName; this.lastName = lastName; } } This feels overly redundant (I imagine typing "firstName" once, instead of thrice could be enough…), but I can't think of a proper alternative. Any ideas? Maybe I just don't know about a certain design pattern I should be using here? Edit - I think I need to elaborate a little. I'm not asking how to make the example code "better", but rather, "shorter". In its current state, all member names appear 3 times (declaration, initialization, constructor arguments), and it feels rather redundant. So I'm wondering if there is a pattern (or semantic sugar) to get (roughly) the same behavior, but with less bloat. I apologize for being unclear initially.

    Read the article

  • CDI, Hibernate JSF on jetty

    - by Arash
    I am trying to make Weld, hibernate, jsf combination work on Jetty. The best approach I found on internet was http://www.laliluna.de/articles/2011/01/12/jboss-weld-jpa-hibernate.html . It was a pain to clean up the dependencies, but I managed to go through that. Now it works for me except the initialization part of the EntityManagerStoreImpl. It seems the weld listener for jetty does not produce a ContainerInitialized event, so the init method which observes this event is never called. Could you tell me please what is the best way to bootstrap this class in the jetty environment? thanks!

    Read the article

  • hibernate versioning parent entity

    - by Priit
    Consider two entities Parent and Child. Child is part of Parent's transient collection Child has a ManyToOne mapping to parent with FetchType.LAZY Both are displayed on the same form to a user. When user saves the data we first update Parent instance and then Child collection (both using merge). Now comes the tricky part. When user modifies only Child property on the form then hibernate dirty checking does not update Parent instance and thus does not increase optimistic locking version number for that entity. I would like to see situation where only Parent is versioned and every time I call merge for Parent then version is always updated even if actual update is not executed in db.

    Read the article

  • Is my TFS2010 backup/restore hosed?

    - by bwerks
    Hi all, I recently set up a sandbox TFS to test TFS-specific features without interfering with the production TFS. I was happy I did this sooner than I thought--I hadn't been backing up the encryption key from SSRS and upon restoring the reporting databases, they remained inactive, requiring initialization that could only come from applying the encryption key. Said encryption key was lost when I nuked the partition after backing up the TFS databases. The only option I seemed to have is to delete the encrypted data. I'm fine with this, since there wasn't much in there to begin with, however once they're deleted I'm not quite sure how to configure TFS to recognize a new installation of these services while using the restored versions of everything else. Unfortunately, the TFS help file doesn't seem to account for this state though. Is there a way to essentially rebuild the reporting and analysis databases? Or are they gone forever?

    Read the article

  • Proper way to have an endless worker thread?

    - by Neil N
    I have an object that requires a lot of initialization (1-2 seconds on a beefy machine). Though once it is initialized it only takes about 20 miliseconds to do a typical "job" In order to prevent it from being re-initialized every time an app wants to use it (which could be 50 times a second or not at all for minutes in typical usage), I decided to give it a job que, and have it run on its own thread, checking to see if there is any work for it in the que. However I'm not entirely sure how to make a thread that runs indefinetly with or without work. Here's what I have so far, any critique is welcomed private void DoWork() { while (true) { if (JobQue.Count > 0) { // do work on JobQue.Pop() } else { System.Threading.Thread.Sleep(50); } } } After thought: I was thinking I may need to kill this thread gracefully insead of letting it run forever, so I think I will add a Job type that tells the thread to end. Any thoughts on how to end a thread like this also appreciated.

    Read the article

  • Migrating a simple application from Application Delegate to ViewController Class

    - by eco_bach
    Hi Frst of all wanted to send out a huge thanks for the great feedback and support. I have a simple application working, right now simply loads a sequence of images and alows the user to step thru the images by clicking a button. All of my logic is in my Application Delegate class, with the image loading, initialization of UIImage Views etc happening in my applicationDidFinishLaunching method. My next step is to migrate as much as possible all of the logic from this class to a ViewController, to take advantage of the extra functionality etc in viewcontrollers. All my images and imageViews are initialized like the following in my applicationDidFinishLaunching. img = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@image1.jpg" ofType:nil]]; imgView = [[UIImageView alloc] initWithImage:img]; How would I migrate this to a ViewController based application? Where would I put all of the logic currently in my applicationDidFinishLaunching method, or for loading of images, is it necessary to only load them here? Any feedback, tips, suggestions appreciated.

    Read the article

  • Is there a quick way to build & install to iPhone (from XCode) without starting the app?

    - by Olie
    In XCode, I can use CMD-R to run (or CMD-Y to debug), and my app will compile, install on the phone & start-up. (I've already prepped my phone & XCode so this part works as expected.) What I'd LIKE to do is type CMD-<something else> and have my program compile & install on the phone, but NOT start-up. I realize that I can just CMD-B to build, then go through some rigamarole to deploy, but I'm hoping one of you smart-folk can tell me the lazy-man's shortcut for all of this. Thanks!

    Read the article

< Previous Page | 61 62 63 64 65 66 67 68 69 70 71 72  | Next Page >