synchronization

Wanted: Cross-process synch that doesn't suffer from AbandonedMutexException

一世执手 提交于 2019-12-01 22:08:52
I have several threads that acquire Mutexes and then terminate. The mutexes are stored in a main repository, and are properly released when the program exists. However, when the thread that allocated a Mutex exists, the mutex gets released automatically, and subsequent acquire AbandonedMutexException (also according to the documentation ). How can I avoid this exception, and keep using a Mutex even after the allocating thread finished? Is there another, more appropriate synchronization construct in .Net that doesn't have this limitation. Note - I am looking for a cross-process synch mechanism

Synchronise push_back and std::thread

元气小坏坏 提交于 2019-12-01 21:48:36
My code void build(std::vector<RKD <DivisionSpace> >& roots, ...) { try { // using a local lock_guard to lock mtx guarantees unlocking on destruction / exception: std::lock_guard<std::mutex> lck (mtx); roots.push_back(RKD<DivisionSpace>(...)); } catch (const std::bad_alloc&) { std::cout << "[exception caught when constructing tree]\n"; return; } } Now, the actual work should be done serially, not in parallel. The constructor of RKD can run in parallel with other constructors of RKD . However, pushing the objects back in std::Vector is a critical section, right? The number of the objects I am

Microsoft Sync Framework - How to reprovision a table (or entire scope) after schema changes?

冷暖自知 提交于 2019-12-01 21:11:23
I have already setup syncing with Microsoft Sync Framework, and now I need to add fields to a table. How do I re-provision the databases? The setup is exceedingly simple: Two SQL Express 2008 servers The scope includes the entire database Using Microsoft Sync Framework 2.0 Synchronizing by direct access. Using the standard new SqlSyncProvider Do I make the structural changes at both ends? Or do I only change one server and let Sync Framework somehow propagate the change? Do I need to delete the _tracking tables and/or the stored procedures? How about the triggers? Has anyone been using the

clarifications on full memory barriers involved by pthread mutexes

夙愿已清 提交于 2019-12-01 21:09:34
I have heard that when dealing with mutexes, the necessary memory barriers are handled by the pthread API itself. I would like to have more details on this matter. Are these claimings true, at least on the most common architectures around? Does the compiler recognize this implicit barrier, and avoids reordering of operations/read from local registers when generating the code? When is the memory barrier applied: after successfully acquiring a mutex AND after releasing it? The POSIX specification lists the functions that must "synchronize memory with respect to other threads" , which includes

Making synchronous calls with RestKit

ぃ、小莉子 提交于 2019-12-01 21:04:32
I have an objectMapping for my entity User RKObjectMapping* userMapping = [RKObjectMapping mappingForClass:[User class]]; [userMapping mapKeyPath:@"first_name" toAttribute:@"firstName"]; [userMapping mapKeyPath:@"last_name" toAttribute:@"lastName"]; [manager.mappingProvider setMapping:userMapping forKeyPath:@"users"]; [manager.mappingProvider setSerializationMapping:[userMapping inverseMapping] forClass:[User class]]; And I want to save his profile when the application goes background: - (void)applicationDidEnterBackground:(UIApplication *)application { [[RKObjectManager sharedManager]

Is there such a synchronization tool as “single-item-sized async task buffer”?

徘徊边缘 提交于 2019-12-01 20:58:12
Many times in UI development I handle events in such a way that when an event first comes - I immediately start processing, but if there is one processing operation in progress - I wait for it to complete before I process another event. If more than one event occurs before the operation completes - I only process the most recent one. The way I typically do that my process method has a loop and in my event handler I check a field that indicates if I am currently processing something and if I am - I put my current event arguments in another field that is basically a one item sized buffer and

Many binary files synchronization

陌路散爱 提交于 2019-12-01 20:55:24
I have about 100 000 files on office server (images, pdf's, etc...) Each day files count grows about 100-500 items, and about 20-50 old files changes. What is the best way to synchronize Web-server with these files? Can any system like Mercurial, GIT help? (On office server, I'll commit changes, and web-server periodically do updates)? Second problem is, that on Web-server I have user-generated-content (binary-files) (other files). Each day this users upload about 1000-2000 new files. Old files don't change. And I need to backup these files to local machine. Can any system like Merurial, GIT

Why does enumerating through a collection throw an exception but looping through its items does not

荒凉一梦 提交于 2019-12-01 19:34:56
问题 I was testing out some synchronization constructs and I noticed something that confused me. When I was enumerating through a collection while writing to it at the same time, it threw an exception (this was expected), but when I looped through the collection using a for loop, it did not. Can someone explain this? I thought that a List does not allow a reader and writer to operate at the same time. I would have expected looping through the collection to exhibit the same behavior as using an

Javascript thread-handling and race-conditions

心不动则不痛 提交于 2019-12-01 19:29:05
问题 Lets asume I have a code like the following: var shared = 100; function workWithIt(){ shared += 100; } setTimeout(workWithIt, 500); setTimeout(workWithIt, 500); Ideally, this piece of code should add 200 to the variable shared , which is 300 afterwards. But, as I know from c , there can be some implications, if the operation += is split into multiple commands. Lets say, that this is the execution-order of the function: setTimeout() --> create Thread A setTimeout() --> create Thread B wait

Pass each list item to a new thread one by one [duplicate]

喜你入骨 提交于 2019-12-01 18:43:10
This question already has an answer here: Captured variable in a loop in C# 8 answers What I'm trying to do is very simple, I scan a list of strings, then, I pass each string to a new thread for printing. using System; using System.Collections.Generic; using System.Threading; namespace MultithreadingSynchronization { class Program { static void Main(string[] args) { List<string> stringList = new List<string> { "server1", "server2", "server3", "server4", "server5", "server6", "server7", "server8", "server9"}; foreach (string server in stringList) { ThreadStart work = delegate { Threadjob(server