locking

How to call a python function from a foreign language thread (C++)

Hi, I am developing a program that use DirectShow to grab audio data from media files. DirectShow use thread to pass audio data to the callback function in my program, and I let that callback function call another function in Python. I use Boost.Python to wrapper my library, the callback function : class PythonCallback { private: ...

How expensive is Java Locking?

In general, how expensive is locking in Java? Specifically in my case: I have a multi-threaded app in which there is one main loop that takes objects off a DelayQueue and processes them (using poll()). At some point a different thread will have to remove errant elements from the queue (using remove()). Given that the remove() is relat...

FileChannel & RandomAccessFile don't seem to work

To put it simple: a swing app that uses sqlitejdbc as backend. Currently, there's no problem launching multiple instances that work with the same database file. And there should be. The file is locked (can't delete it while the app is running) so the check should be trivial. Turns out not. File f = new File("/path/to/file/db.sqlite"...

python, sqlite error? db is locked? but it isnt?

I get "database table is locked" error in my sqlite3 db. My script is single threaded, no other app is using the program (i did have it open once in "SQLite Database Browser.exe"). I copied the file, del the original (success) and renamed the copy so i know no process is locking it yet when i run my script everything in table B cannot be...

Does "Double Checked Locking" work in coldfusion

I have used a version of double checked locking in my CF app (before I knew what double checked locking was) Essentially I check for the exsistance of an object. If it is not present I lock (usually using a named lock) and before I try and create the object I check for exsistance again. I thought this was a neet way to stop multiple obj...

How to let humans and programs access the same file without stepping on each others' toes.

Suppose I have a file, urls.txt, that contains a list of URLs I'm monitoring. My monitoring script edits that file occasionally, say, to indicate whether each URL is reachable. I'd like to also manually edit that file, to add to or change the list of URLs. How can I allow that such that I don't have to think about it when manually edi...

Will calling a File.Exist put a lock on a file?

Hi, If I am trying to delete a file, but at the same time another process is performing a File.Exists(...) on the same file, will that potentially lock the file and cause my process to fail? ...

How will a lock respond to a race condition?

How long will a thread wait for a race condition in the following scenario? A file is added to a collection: lock(mylock) { // add to collection } It is then removed from the collection in a similiar manner. If a thread is trying to add to the collection while the service is removing it from the collection, who wins? Or is...

Lock Statement C#

Say I have three threads that need access to a collection and I use a lock block around the access in each thread. The following happens... (1) Thread 1 gets the lock on the collection (2) Thread 2 gets blocked (3) Thread 3 gets blocked When Thread 1 releases the lock, who gets to take the lock next? Is it FIFO access? Thanks ...

ASP.NET 2.0 Membership: ValidateUser not locking out the user?

Hi I am using the default SQLMembershipProvider in my ASP.NET 2.0 website, and expect the Membership.ValidateUser to lock-out the user after entering a number of wrong passwords (5, in my case) but ValidateUser doesn't seem to be caring about keeping count of bad password attempts and locking out the user. What's wrong? The Membership...

Efficient transaction, record locking

I've got a stored procedure, which selects 1 record back. the stored procedure could be called from several different applications on different PCs. The idea is that the stored procedure brings back the next record that needs to be processed, and if two applications call the stored proc at the same time, the same record should not be b...

fcntl, lockf, which is better to use for file locking?

Looking for information regarding the advantages and disadvantages of both fcntl and lockf for file locking. For example which is better to use for portability? I am currently coding a linux daemon and wondering which is better suited to use for enforcing mutual exclusion. ...

release a db lock when php session ends?

Suppose a user is editing a record from a database, in the schema you have a field named 'lock' so users can not edit concurrently the same record, once the user ends editing you set lock = false to allow other users to edit the record. My question is, can i run some code when php session ends, so if a user walks away from computer, clo...

Find out who is locking a file on a network share

I want to known who is locking a file on a network share. Here is the problem : the network share is on a NAS, so I can't log on. I need a tool to find out remotely who is locking the file. It is not practical to reboot the NAS every time, because there are several users. Handle.exe, Process Explorer and PsFile seems to be limited to f...

Is this a safe version of double-checked locking?

Slightly modified version of canonical broken double-checked locking from Wikipedia: class Foo { private Helper helper = null; public Helper getHelper() { if (helper == null) { synchronized(this) { if (helper == null) { // Create new Helper instance and store reference on ...

Is this is a bug in .net Monitor/lock statement or does MessageBox.Show behaves differently?

Imagine you have two buttons on the win form. What do you think should be the behavior when user presses the "button 1" with the below code? Should it display all 5 message box in one go, or one by one - MessageBox.Show statement is inside a lock statement? public partial class Form1 : Form { public Form1() { Initializ...

Java keeps lock on files for no apparent reason

Despite closing streams in finally clauses I seem to constantly run into cleaning up problems when using Java. File.delete() fails to delete files, Windows Explorer fails too. Running System.gc() helps sometimes but nothing short of terminating the VM helps consistently and that is not an option. Does anyone have any other ideas I could...

SQLite synchronization when accessed by applications on different machines

I'm wondering how SQLite implements it. Is it based on file-locking? Surely the entire DB isn't locked for every user that accesses it; that would be extremely inefficient. Is it based on multiple files or just one big file? Would be nice if someone could give a short overview of how synchronization and locking is done in sqlite, or, o...

Where can I find a good introduction on SQL locking and transaction strategies

I'm using locks and transactions a bit like a VBA excel programmer trying to write a multithreaded c++ server for the first time... I've tried to ask my coworkers for advice, but while we're all quite good (or so we think) at designing complex databases, writing fast and efficient queries, using index and constraints when it's needed, a...

Syntax for interruptible lock in C#

I suspect this is a very dumb question: what is the correct syntax for an interruptible lock statement in C#? E.g. get lock; if lock is interrupted before locked code finishes, return false out of the enclosing method. Probably totally the wrong terminology... Thanks. ...