Search Results

Search found 14383 results on 576 pages for 'double checked locking'.

Page 2/576 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • jquery - radio button not checked on page load, but checked on same function call later

    - by Bill Zimmerman
    Hi, I'm having a strange problem with jquery. When my page loads, I dynamically create some simple radio buttons in a special i've created. However, the default radio button is not checked. It is checked however when the change() event is triggered later, but is never checked the first time. Can someone help? I am certain that the change() event is triggered on the page load, because the rest of the HTML is added dynamically and I can see it. The basic idea is when the page loads, I bind an event handler, and then immediately call it to make sure that the default options are loaded. $(document).ready(function() { $(".options select[name=App]").change(onAppChange); //trigger the change function in the dropdown to populate default options $(".options select[name=App]").change() } Here is the simple onAppChange() function: function onAppChange() { var val = $(this).val(); var app_options = $(this).closest(".options").find(".app_options"); //clear the app_options app_options.empty(); var newOptions = ''; switch(val) { case 'testapp': newOptions='\ <fieldset>\ <legend>TestApp</legend>\ Option 1:\ <label>\ <input type="radio" name="option1" value="value1" checked>\ Value1\ </label>\ \ <label>\ <input type="radio" name="option1" value="value2">\ value2\ </label>\ \ </fieldset>'; break; case 'todo': //for testing newOptions='FOO'; break; } app_options.append(newOptions); } Yes, I am aware that I could use javascript to automatically select a radio button again, but I asked this question because I wanted to understand why this is happening. When using and , there doesn't seem to be any problem. Only with radio buttons. Why does the behavior differ when the same change() event is triggered? What is going on behind the scenes?

    Read the article

  • When do you use float and when do you use double

    - by Jakub Zaverka
    Frequently in my programming experience I need to make a decision whether I should use float or double for my real numbers. Sometimes I go for float, sometimes I go for double, but really this feels more subjective. If I would be confronted to defend my decision, I would probably not give sound reasons. When do you use float and when do you use double? Do you always use double, only when memory constraints are present you go for float? Or you use always float unless the precision requirement requires you to use double? Are there some substantial differences regarding computational complexity of basic arithemtics between float and double? What are the pros and cons of using float or double? And have you even used long double?

    Read the article

  • How to improve INSERT INTO ... SELECT locking behavior

    - by Artem
    In our production database, we ran the following pseudo-code SQL batch query running every hour: INSERT INTO TemporaryTable (SELECT FROM HighlyContentiousTableInInnoDb WHERE allKindsOfComplexConditions are true) Now this query itself does not need to be fast, but I noticed it was locking up HighlyContentiousTableInInnoDb, even though it was just reading from it. Which was making some other very simple queries take ~25 seconds (that's how long that other query takes). Then I discovered that InnoDB tables in such a case are actually locked by a SELECT! http://www.mysqlperformanceblog.com/2006/07/12/insert-into-select-performance-with-innodb-tables/ But I don't really like the solution in the article of selecting into an OUTFILE, it seems like a hack (temporary files on filesystem seem sucky). Any other ideas? Is there a way to make a full copy of an InnoDB table without locking it in this way during the copy. Then I could just copy the HighlyContentiousTable to another table and do the query there.

    Read the article

  • What interprocess locking calls should I monitor?

    - by Matt Joiner
    I'm monitoring a process with strace/ltrace in the hope to find and intercept a call that checks, and potentially activates some kind of globally shared lock. While I've dealt with and read about several forms of interprocess locking on Linux before, I'm drawing a blank on what to calls to look for. Currently my only suspect is futex() which comes up very early on in the process' execution. Update0 There is some confusion about what I'm after. I'm monitoring an existing process for calls to persistent interprocess memory or equivalent. I'd like to know what system and library calls to look for. I have no intention call these myself, so naturally futex() will come up, I'm sure many libraries will implement their locking calls in terms of this, etc. Update1 I'd like a list of function names or a link to documentation, that I should monitor at the ltrace and strace levels (and specifying which). Any other good advice about how to track and locate the global lock in mind would be great.

    Read the article

  • Does my Dictionary must use locking mechanism?

    - by theateist
    Many threads have access to summary. Each thread will have an unique key for accessing the dictionary; Dictionary<string, List<Result>> summary; Do I need locking for following operations? summary[key] = new List<Result>() summary[key].Add(new Result()); It seems that I don't need locking because each thread will access dictionary with different key, but won't the (1) be problematic because of adding concurrently new record to dictionary with other treads?

    Read the article

  • Return Double from Boost thread

    - by Benedikt Wutzi
    Hi I have an Boost thread which should return a double. The function looks like this: void analyser::findup(const double startwl, const double max, double &myret){ this->data.begin(); for(int i = (int)data.size() ; i >= 0;i--){ if(this->data[i].lambda > startwl){ if(this->data[i].db >= (max-30)) { myret = this->data[i+1].lambda; std::cout <<"in thread " << myret << std::endl; return; } } } } this function is called by another function: void analyser::start_find_up(const double startwl, const double max){ double tmp = -42.0; boost::thread up(&analyser::findup,*this, startwl,max,tmp); std::cout << "before join " << tmp << std::endl; up.join(); std::cout << "after join " << tmp << std::endl; } Anyway I've tried and googled almost anything but i can't get it to return a value. The output looks like this right now. before join -42 in thread 843.487 after join -42 Thanks for any help.

    Read the article

  • Are multiply-thrown Exceptions checked or runtime?

    - by froadie
    I have an Exception chain in which method1 throws an Exception to method2 which throws the Exception on to main. For some reason, the compiler forces me to deal with the error in method2 and marks it as an error if I don't, indicating that it's a checked Exception. But when the same Exception is thrown further down the line to main, the compiler allows me to ignore it and doesn't display any errors. The original Exception in method1 is a ParseException, which is checked. But the method has a generic throws Exception clause in the header, and the same object is thrown to method2, which has an identical throws Exception clause. When and how does this Exception lose the status of being checked / caught by the compiler? Edited to clarify: public void method1() throws Exception{ // code that may generate ParseException } public void method2() throws Exception{ method1(); //compiler error } public static void main(String[] args){ method2(); //ignored by compiler }

    Read the article

  • Opening password protected Excel 2007 documents by double clicking from My documents does not work u

    - by erik-van-gorp
    When all of the following conditions are true, excel will open (most of the time) but will not open the document itself. No error is displayed. This only occurs with Excel files, Word and powerpoint do open perfectly. Conditions : OS is "Windows 7 Professional 64-bit" office is "Office 2007 Ultimate". excel file is in .xls (2003 format) excel file is password protected excel file is in "My Documents" (or a subfolder of it) file is double-clicked from explorer under Windows 7. Following options do open the excel file as it should : right click and selecting the (bold) open action single click the file and pressing enter moving the file to the desktop and double-click it. non password protected files do open from the same directory. Actions taken not resolving the problem: - reboot - repair office installation - system restore does not work because of Antivirus application installed (message from system restore, using "Symantec Internet Security 2010") Anyone any idea ?

    Read the article

  • Naming Convention for Dedicated Thread Locking objects

    - by Chris Sinclair
    A relatively minor question, but I haven't been able to find official documentation or even blog opinion/discussions on it. Simply put: when I have a private object whose sole purpose is to serve for private lock, what do I name that object? class MyClass { private object LockingObject = new object(); void DoSomething() { lock(LockingObject) { //do something } } } What should we name LockingObject here? Also consider not just the name of the variable but how it looks in-code when locking. I've seen various examples, but seemingly no solid go-to advice: Plenty of usages of SyncRoot (and variations such as _syncRoot). Code Sample: lock(SyncRoot), lock(_syncRoot) This appears to be influenced by VB's equivalent SyncLock statement, the SyncRoot property that exists on some of the ICollection classes and part of some kind of SyncRoot design pattern (which arguably is a bad idea) Being in a C# context, not sure if I'd want to have a VBish naming. Even worse, in VB naming the variable the same as the keyword. Not sure if this would be a source of confusion or not. thisLock and lockThis from the MSDN articles: C# lock Statement, VB SyncLock Statement Code Sample: lock(thisLock), lock(lockThis) Not sure if these were named minimally purely for the example or not Kind of weird if we're using this within a static class/method. Several usages of PadLock (of varying casing) Code Sample: lock(PadLock), lock(padlock) Not bad, but my only beef is it unsurprisingly invokes the image of a physical "padlock" which I tend to not associate with the abstract threading concept. Naming the lock based on what it's intending to lock Code Sample: lock(messagesLock), lock(DictionaryLock), lock(commandQueueLock) In the VB SyncRoot MSDN page example, it has a simpleMessageList example with a private messagesLock object I don't think it's a good idea to name the lock against the type you're locking around ("DictionaryLock") as that's an implementation detail that may change. I prefer naming around the concept/object you're locking ("messagesLock" or "commandQueueLock") Interestingly, I very rarely see this naming convention for locking objects in code samples online or on StackOverflow. Question: What's your opinion generally about naming private locking objects? Recently, I've started naming them ThreadLock (so kinda like option 3), but I'm finding myself questioning that name. I'm frequently using this locking pattern (in the code sample provided above) throughout my applications so I thought it might make sense to get a more professional opinion/discussion about a solid naming convention for them. Thanks!

    Read the article

  • mysql row locking via php

    - by deezee
    I am helping a friend with a web based form that is for their business. I am trying to get it ready to handle multiple users. I have set it up so that just before the record is displayed for editing I am locking the record with the following code. $query = "START TRANSACTION;"; mysql_query($query); $query = "SELECT field FROM table WHERE ID = \"$value\" FOR UPDATE;"; mysql_query($query); (okay that is greatly simplified but that is the essence of the mysql) It does not appear to be working. However, when I go directly to mysql from the command line, logging in with the same user and execute START TRANSACTION; SELECT field FROM table WHERE ID = "40" FOR UPDATE; I can effectively block the web form from accessing record "40" and get the timeout warning. I have tried using BEGIN instead of START TRANSACTION. I have tried doing SET AUTOCOMMIT=0 first and starting the transaction after locking but I cannot seem to lock the row from the PHP code. Since I can lock the row from the command line I do not think there is a problem with how the database is set up. I am really hoping that there is some simple something that I have missed in my reading. FYI, I am developing on XAMPP version 1.7.3 which has Apache 2.2.14, MySQL 5.1.41 and PHP 5.3.1. Thanks in advance. This is my first time posting but I have gleaned alot of knowledge from this site in the past.

    Read the article

  • C# Checked exceptions

    - by Ryan B.
    One feature I really liked in Java that isn't in C# is checked exceptions, Is there any way to simulate or turn on checked exceptions in Visual Studio? Yes I know a lot of people dislike them, but I find they can be helpful.

    Read the article

  • TreeView nodes always have .Checked=true on postback even when not checked in UI

    - by GISmatters
    I have a treeview in my .aspx: <asp:TreeView ID="tvDocCatAndType" runat="server" /> Not much else going on in the page -- two <asp:LinkButtons> and one <asp:Label>; the page is a child of a master page, so these controls are within a <asp:Content> control. I populate the treeview in code -- just 3 node levels, including the root node. All nodes have checkboxes, and I initialize all node.Checked to true. I have some Javascript to do the usual check/uncheck up and down the tree as parent and child node checkboxes are toggled. No matter how many checkboxes I clear in the UI, on postback every single node has node.Checked = true regardless of the state of the checkbox in the UI. This is not the first time I've used a treeview, but I've never had this problem before. I created this page by light adaptation of an earlier project that works fine. Thanks in advance for any helpful comments or questions, Chris

    Read the article

  • Javascript: addClassName if input is checked and removeClassName if it was un-checked

    - by BoDiE2003
    Im trying to select all the li tags of the document and check if it hasClassName('yes') so if it has, it will remove it. But im having a TypeError: Object [object HTMLLIElement], has no method 'hasClassName' error. This is the DOM method: document.observe("dom:loaded", function() { $(document.body).select('input').each(function(element) { element.observe('click', function() { init(); }); init(); }); }); The previous code will take the init fuction and check the if there are checked inputs and add them the 'yes' class name, but if I un-check those inputs, the class remains. This is the funcion that Im trying to do dynamic (add and remove class 'yes'); function init() { $(document.body).select('input').each(function(element) { if (element.checked) { element.up('li').addClassName('yes'); } if ($(document.body).select('li').hasClassName('yes')) { element.removeClassName('yes'); } }) } Can you help me solving the last part of this function, so the removeclassname method will work? Thank you

    Read the article

  • jQuery; combine user click and :checked

    - by user275074
    I have two blocks of code which basically check for 1) a click event on a radio button e.g. $("input[id='frmSkill']").click(function(){ //do something }); And 2) a block of code to check if a radio button is :checked, if so, then perform some actions e.g. if($("input[id='frmSkill']:checked").val()){ //do something }); What I'd like to do is combine the two in order to reduce the code as the actions performed under each are the same.

    Read the article

  • C++ double division by 0.0 versus DBL_MIN

    - by wonsungi
    When finding the inverse square root of a double, is it better to clamp invalid non-positive inputs at 0.0 or MIN_DBL? (In my example below double b may end up being negative due to floating point rounding errors and because the laws of physics are slightly slightly fudged in the game.) Both division by 0.0 and MIN_DBL produce the same outcome in the game because 1/0.0 and 1/DBL_MIN are effectively infinity. My intuition says MIN_DBL is the better choice, but would there be any case for using 0.0? Like perhaps sqrt(0.0), 1/0.0 and multiplication by 1.#INF000000000000 execute faster because they are special cases. double b = 1 - v.length_squared()/(c*c); #ifdef CLAMP_BY_0 if (b < 0.0) b = 0.0; #endif #ifdef CLAMP_BY_DBL_MIN if (b <= 0.0) b = DBL_MIN; #endif double lorentz_factor = 1/sqrt(b); double division in MSVC: 1/0.0 = 1.#INF000000000000 1/DBL_MIN = 4.4942328371557898e+307

    Read the article

  • Swap bits in c++ for a double

    - by hidayat
    Im trying to change from big endian to little endian on a double. One way to go is to use double val, tmp = 5.55; ((unsigned int *)&val)[0] = ntohl(((unsigned int *)&tmp)[1]); ((unsigned int *)&val)[1] = ntohl(((unsigned int *)&tmp)[0]); But then I get a warning: "dereferencing type-punned pointer will break strict-aliasing rules" and I dont want to turn this warning off. Another way to go is: #define ntohll(x) ( ( (uint64_t)(ntohl( (uint32_t)((x << 32) >> 32) )) << 32) | ntohl( ((uint32_t)(x >> 32)) ) ) val = (double)bswap_64(unsigned long long(tmp)); //or val = (double)ntohll(unsigned long long(tmp)); But then a lose the decimals. Anyone know a good way to swap the bits on a double without using a for loop?

    Read the article

  • Is this a dangerous locking pattern?

    - by Martin
    I have an enumerator written in C#, which looks something like this: try { ReadWriteLock.EnterReadLock(); yield foo; yield bar; yield bash; } finally { ReadWriteLock.ExitReadLock(); } I believe this may be a dangerous locking pattern, as the ReadWriteLock will only be released if the enumeration is complete, otherwise the lock is left hanging and is never released, am I correct? If so, what's the best way to combat this?

    Read the article

  • Android pattern locking

    - by JonF
    I have been able to lock the screen using LOCK_PATTERN_ENABLED, however in many cases when I enable this pattern locking it will take any pattern and move past the pattern check. Has anyone else run across this?

    Read the article

  • Java string to double conversion.

    - by wretrOvian
    Hi, I've been reading up on the net about the issues with handling float and double types in java. Unfortunately, the image is still not clear. Hence, i'm asking here direct. :( My MySQL table has various DECIMAL(m,d) columns. The m may range from 5 to 30. d stays a constant at 2. Question 1. What equivalent data-type should i be using in Java to work (i.e store, retrieve, and process) with the size of the values in my table? (I've settled with double - hence this post). Question 2. While trying to parse a double from a string, i'm getting errors Double dpu = new Double(dpuField.getText()); for example - "1" -> java.lang.NumberFormatException: empty String "10" -> 1.0 "101" -> 10.0 "101." -> 101.0 "101.1" -> 101.0 "101.19" -> 101.1 What am i doing wrong? What is the correct way to convert a string to a double value? And what measures should i take to perform operations on such values?

    Read the article

  • [C#] Convert string to double with 2 digit after decimal separator

    - by st.stoqnov
    All began with these simple lines of code: string s = "16.9"; double d = Convert.ToDouble(s); d*=100; The result should be 1690.0, but it's not. d is equal to 1689.9999999999998. All I want to do is to round a double to value with 2 digit after decimal separator. Here is my function. private double RoundFloat(double Value) { float sign = (Value < 0) ? -0.01f : 0.01f; if (Math.Abs(Value) < 0.00001) Value = 0; string SVal = Value.ToString(); string DecimalSeparator = System.Globalization.CultureInfo.CurrentCulture.NumberFormat.CurrencyDecimalSeparator; int i = SVal.IndexOf(DecimalSeparator); if (i > 0) { int SRnd; try { // ????? ??????? ????? ???? ?????????? ?????????? SRnd = Convert.ToInt32(SVal.Substring(i + 3, 1)); } catch { SRnd = 0; } if (SVal.Length > i + 3) SVal = SVal.Substring(0, i + 3); //SVal += "00001"; try { double result = (SRnd >= 5) ? Convert.ToDouble(SVal) + sign : Convert.ToDouble(SVal); //result = Math.Round(result, 2); return result; } catch { return 0; } } else { return Value; } But again the same problem, converting from string to double is not working as I want. A workaround to this problem is to concatenate "00001" to the string and then use the Math.Round function (commented in the example above). This double value multiplied to 100 (as integer) is send to a device (cash register) and this values must be correct. I am using VS2005 + .NET CF 2.0 Is there another more "elegant" solution, I am not happy with this one.

    Read the article

  • Making sure unsigned int/long always execute in checked context in C#

    - by theburningmonk
    Has anyone found it strange that the default context for uint and ulong is unchecked rather than checked considering that they are meant to represent values that can never be negative? So if some code is trying to violate that constraint it seems to me the natural and preferred behaviour would be to throw an exception rather than returning the max value instead (which can easily leave important pieces of data in an invalid state and impossible to revert..). Is there an existing attribute which can be applied to either class/assembly so that it always performs arithmetic operations in a checked context? I was thinking of writing one myself (as an aspect using PostSharp) but would be great if there's one already. Many thanks,

    Read the article

  • checkbox checked not appearing as checked in controller

    - by user281180
    I have the following code in my view <tr><td><%=Html.Hidden("ProjectID["+(count)+"]",item.ProjectID)%><%=item.ProjectName%></td><td><input type="checkbox" name="Name[<%=count%>]" /></td></tr> In my controller, the checkboxes value appear false depsite having been checked in on the web page. how can I correct that?

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >