locking

Perforce File Locked By Departed User

心不动则不痛 提交于 2020-01-10 08:44:10
问题 I have a file that is locked/checked out exclusively by a user who is no longer with the company. I need to make changes and want to know how to "steal the lock". 回答1: Ask your perforce admin to remove the lock by issuing p4 unlock -f <file> PS: To reuse the departed user's license, your perforce admin might also want clean up the files left opened by him. He can revert the pending edits if they are useless or transfer them to another user via "p4 reopen". The "reopen" and "revert after

Primitive synchronization primitives — safe?

◇◆丶佛笑我妖孽 提交于 2020-01-10 05:07:06
问题 On constrained devices, I often find myself "faking" locks between 2 threads with 2 bools. Each is only read by one thread, and only written by the other. Here's what I mean: bool quitted = false, paused = false; bool should_quit = false, should_pause = false; void downloader_thread() { quitted = false; while(!should_quit) { fill_buffer(bfr); if(should_pause) { is_paused = true; while(should_pause) sleep(50); is_paused = false; } } quitted = true; } void ui_thread() { // new Thread(downloader

Pessimistic lock in T-SQL

故事扮演 提交于 2020-01-10 05:05:33
问题 If i SELECT a row for updating in MS SQL Server, and want to have it locked till i either update or cancel, which option is better :- 1) Use a query hint like UPDLOCK 2) Use REPEATABLE READ isolation level for the transaction 3) any other option. Thanks, Chak. 回答1: Neither. You almost never want to hold a transaction open while your user is inputting data. If you have to implement a pessimistic lock like this, people generally do it by rolling their own functionality. Consider the full

is locking necessary for Dictionary lookup?

微笑、不失礼 提交于 2020-01-10 01:20:32
问题 lock(dictionaryX) { dictionaryX.TryGetValue(key, out value); } is locking necessary while doing lookups to a Dictionary ? THe program is multithreaded, and while adding key/value to dict. dict is being locked. 回答1: Locking is only needed when you are synchronizing access to a resource between threads. As long as there are not mulitple threads involved then locking is not needed here. In the context of updating and reading the value from multiple threads, yes a lock is absolutely necessary. In

What does use_locking=True do in TensorFlow optimizers?

限于喜欢 提交于 2020-01-09 10:50:30
问题 Does it only protect against asynchronous updates or does it also cause other access to the variable to wait for the update? I'm using the same model for training and inference at the same time and want to make sure that inference is always done on a consistent model. 回答1: Passing use_locking=True when creating a TensorFlow optimizer, or a variable assignment op, causes a lock to be acquired around the relevant updates to the variable. Other optimizers/assignments on the same variable also

Locking Executing Files: Windows does, Linux doesn't. Why?

情到浓时终转凉″ 提交于 2020-01-09 05:58:10
问题 I noticed when a file is executed on Windows (.exe or .dll), it is locked and cannot be deleted, moved or modified. Linux, on the other hand, does not lock executing files and you can delete, move, or modify them. Why does Windows lock when Linux does not? Is there an advantage to locking? 回答1: Linux has a reference-count mechanism, so you can delete the file while it is executing, and it will continue to exist as long as some process (Which previously opened it) has an open handle for it.

Lock/Unlock a cell using conditional formatting

Deadly 提交于 2020-01-07 03:29:16
问题 How can I Lock/Unlock a cell(A1) based on value(yes/no) in another cell(A2) using conditional formatting? 回答1: There's lots of resources online showing how to do this. Here's an article that helped explain it to me: http://database.ittoolbox.com/groups/technical-functional/excel-l/how-to-lockunlock-an-excel-cell-based-on-the-contents-of-another-cell-4625040 In case that link dies, here is the gist of it: To do what you are describing, you will need to create an event procedure that Excel will

Rails ActiveRecord: lock without reload

假如想象 提交于 2020-01-07 00:58:50
问题 Can I lock an ActiveRecord object without reloading it? user = User.find(1) => #<User id: 1, name: "Ed" ...> user.name = "Joe" => "Joe" user.lock! => #<User id: 1, name: "Ed" ...> I could send a raw SQL "SELECT ... FOR UPDATE", but it doesn't seem too clean. 回答1: I ended up adding a method to ActiveRecord::Base : ActiveRecord::Base.class_eval do def lock_without_reload! self.class.lock(true).find(id) true end end 来源: https://stackoverflow.com/questions/38211871/rails-activerecord-lock-without

Rails ActiveRecord: lock without reload

↘锁芯ラ 提交于 2020-01-07 00:58:50
问题 Can I lock an ActiveRecord object without reloading it? user = User.find(1) => #<User id: 1, name: "Ed" ...> user.name = "Joe" => "Joe" user.lock! => #<User id: 1, name: "Ed" ...> I could send a raw SQL "SELECT ... FOR UPDATE", but it doesn't seem too clean. 回答1: I ended up adding a method to ActiveRecord::Base : ActiveRecord::Base.class_eval do def lock_without_reload! self.class.lock(true).find(id) true end end 来源: https://stackoverflow.com/questions/38211871/rails-activerecord-lock-without

java.lang.IllegalMonitorStateException while Executing AsyncTask for Multiple times

怎甘沉沦 提交于 2020-01-06 19:43:51
问题 I refer this solution to run AsyncTask for multiple time. But I am getting following error when i call tryAgain.signal(); E/AndroidRuntime: FATAL EXCEPTION: main Process: com.webapi_testing, PID: 3951 java.lang.IllegalMonitorStateException at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.signal(AbstractQueuedSynchronizer.java:1917) at com.medimanage.webapi_testing.AsyncHttpRequest_Recursive.runAgain(AsyncHttpRequest_Recursive.java:156) at com.medimanage.webapi_testing