synchronization

Capturing the main thread SynchronizationContext or Dispatcher from a library

∥☆過路亽.° 提交于 2019-12-09 10:45:31
问题 I have a C# library that would like to have the ability to Send/Post work to the "main" ui thread (if one exists). This library may be used by: A winforms application A native application (with UI) A console application (with no UI) In the library I'd like to capture something (A SynchronizationContext, a Dispatcher, a Task Scheduler, or something else) during initialization, that will allow me to (at a later time) Send/Post work to the main thread (if the main thread has that ability--i.e.

Do I need to protect this variable with a lock?

谁说胖子不能爱 提交于 2019-12-09 10:07:16
问题 so I have a boolean type in C++ on a multiprocessor machine. The variable starts out life as true, and then there are a few threads, any one or more of which might write it to be false. At the same time, these threads may also read this variable to check its state. I don't care if reading this variable is synchronized with any of the writes, they each happen at different places in the code, and it doesn't matter if it comes before or after any particular write. Now, do I need a lock for this

What to use instead of the “lock” statement when the code is running on multiple machines?

百般思念 提交于 2019-12-09 09:16:42
问题 The lock statement ensures that one thread does not enter a critical section of code while another thread is in the critical section. However, it won't work if the workload is spread across a farm of servers (e.g. a few IIS servers + a load balancer). Does .NET support such a scenario? Is there any class that can be used to control the execution of a critical code section by threads running on multiple machines? If not, is there any standard method of handling such problems? This question was

In Lucene, how can I find out if the IndexSearcher or IndexWriter is being used in another thread or not?

落爺英雄遲暮 提交于 2019-12-09 07:04:52
问题 Lucene documentation states that single instances of IndexSearcher and IndexWriter should be used for each index in the whole application, and across all threads. Also, writes to an index will not be visible until the index is re-opened. So, I'm trying to follow these guides, in a multi-threaded setup. (a few threads writing, multiple user threads searching). I don't want to re-open the index on every change, rather, I want to keep searcher instance not older than a certain amount of time

Out-of-order writes for Double-checked locking

十年热恋 提交于 2019-12-09 05:07:55
问题 In the examples mentioned for Out-of-order writes for double-checked locking scenarios (ref: IBM article & Wikipedia Article) I could not understand the simple reason of why Thread1 would come of out synchronized block before the constructor is fully initialized. As per my understanding, creating "new" and the calling constructor should execute in-sequence and the synchronized lock should not be release till all the work in not completed. Please let me know what I am missing here. 回答1: The

unlocked_ioctl vs normal ioctl

前提是你 提交于 2019-12-09 04:38:59
问题 In my driver's file_operations structure, I have: struct file_operations Fops = { read: device_read, write: device_write, unlocked_ioctl: device_ioctl, ... }; I.e. there is no ioctl field used. Is this sufficient to avoid Big Kernel Lock and enter into device_ioctl() without any synchronization? Or do I have to change ioctl() calls in userspace part of the code too? 回答1: Read this LWN article: http://lwn.net/Articles/119652/ Also sometime between 2.6.33 and a 2.6.35 rc (use git-diff to find

How can one synchronize an external application with a DigitalMicrograph script?

◇◆丶佛笑我妖孽 提交于 2019-12-09 04:37:30
This question has been inspired by the question 'Call script from command line' . How can one write a script which acts on 'trigger events' in an application other than DigitalMicrograph? i.e. some script functionality should be triggered by an external application. The scripting language does not offer many 'external' interfaces in its current state. It is possible to call out to an external process with the command LaunchExternalProcess and wait for the process to complete, but there is no straight-forward way for an external process to call in , i.e. to start a script-action within

iCloud + Core Data today (10th july 2015)

徘徊边缘 提交于 2019-12-09 04:13:40
问题 Some years ago Apple released the iCloud sync of Core Data apps. Then I released an app for iPad / iPhone / MAC with a shared model using the new Apple mechanism. Things have not gone as expected. The sync mechanism sometimes doesn't work. For example, the last months, in my case, rarely the sync ends well through my 3 devices. Uploading objects in general works fine. But the download process of new or deleted objects normaly crash. Apple released some time ago a way to force the devices to

is “Double-Checked Locking is Broken” a java-only thing?

被刻印的时光 ゝ 提交于 2019-12-09 02:36:36
问题 the page at http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html says that double-checked locking is flawed in java. I'm just wondering does it also apply to other languages (C#, Vb, C++, etc) I've read Double checked locking pattern: Broken or not?, Is this broken double checked locking?, How to solve the "Double-Checked Locking is Broken" Declaration in Java? to be truthful i don't know what the common consensus is. some say yes its broken others say no. Anyway, my

Using Git and Dropbox on different machines without Problems?

陌路散爱 提交于 2019-12-08 21:44:31
I already found some similar topics to this, but it wasn't exactly the same. I am working on webdesign projects on three different machines Office Windows PC Home Windows PC MacBook I keep my whole Project-Folder synchronized trough DropBox. This works very well and I'll keep that for sure. I don't share any projects with other persons with DropBox. Now I'd like to use Git for version controlling and to collaborate on code projects with other persons. I still work on all three machines, but actually this three machines still count as " one person " and only one contributor to a git repository,