Questions tagged [shared-resource]
40 questions
74
votes
4 answers
iOS - Ensure execution on main thread
I want to know how to call my function on the main thread.
How do I make sure my function is called on the main thread?
(this follows a previous question of mine).

user236739
- 1,323
- 2
- 15
- 21
40
votes
2 answers
Shared srcDirs between test and androidTest, unresolved references after upgrade to Android Studio Chipmunk (IntelliJ 2021.2.1)
I just upgraded from Bumblebee to Chipmunk, and I am having multiple dependency-resolution issues in my instrumented androidTests.
These are what my source sets look like:
sourceSets {
test.java.srcDirs += 'src/testShared/kotlin'
…

Sean Blahovici
- 5,350
- 4
- 28
- 38
8
votes
2 answers
Python3 Asyncio shared resources between concurrent tasks
I've got a network application written in Python3.5 which takes advantage of pythons Asyncio which concurrently handles each incoming connection.
On every concurrent connection, I want to store the connected clients data in a list. I'm worried that…

Cellydy
- 1,365
- 3
- 15
- 27
7
votes
2 answers
PerformanceCounter creation take a LONG time
I'm working on a charge balancing system and thus I need to know the charge of each machine. PerformanceCounter seem the way to go, but creating the first one take between 38 and 60 sec. Each subsequent new Counter or 'NextValue' call is nearly…

Epineurien
- 71
- 2
- 2
4
votes
2 answers
mutex used in a function defined inside a class doesn't seem to work when that function is called in a thread in main
#include
#include
#include
class ThreadLessons {
private:
std::mutex _threading_mutex_in_class;
public:
ThreadLessons() {}
ThreadLessons(const ThreadLessons &tl) {}
ThreadLessons operator=(const…

robot9
- 43
- 4
3
votes
1 answer
Does a mutex lock itself, or the memory positions in question?
Let's say we've got a global variable, and a global non-member function.
int GlobalVariable = 0;
void GlobalFunction();
and we have
std::mutex MutexObject;
then inside one of the threads, we have this block of code:
{
std::lock_guard…

Physician
- 483
- 2
- 7
3
votes
1 answer
Share a resource between two processes
I want to know the best practices followed to share a queue (resource) between two processes in Python. Here is a what each process is doing:
Process_1: continuously gets data (in json format) from a streaming api
Process_2: is a daemon (similar to…

ajmartin
- 2,379
- 2
- 26
- 42
3
votes
1 answer
Is there a design pattern or basic object-oriented principle that deals with this case of shared resources?
Let's say I have three classes, Solid, Face, and Edge that are defined as follows:
class Solid{
public:
// perform an action on a single edge.
void addFillet(int edgeNum);
// perform an action on a single face
…

wesanyer
- 982
- 1
- 6
- 27
3
votes
1 answer
Using same classes across multiple projects
I have several programs which have nothing in common with each other, they are completely different applications. However, I have several "Swiss knife" classes, which I use in all of those projects.
Currently, when I need to use those classes, I…

user3595338
- 737
- 3
- 11
- 26
3
votes
8 answers
Is a java synchronized method entry point thread safe enough?
I have a Singleton class handling a kind of cache with different objects in a Hashmap.
(The format of a key is directly linked to the type of object stored in the map - hence the map is of )
Three different actions are possible on the map : add,…

David SCHERRER
- 73
- 8
2
votes
2 answers
getter and setters best practice with mutex
I'm feeling a bit overwhelmed when using multiple threads in embedded programming since each and every shared resource ends up with a getter/setter protected by a mutex.
I would really like to understand if a getter of the following sort
static…

Luigi
- 376
- 3
- 16
2
votes
0 answers
Crash when managing shared OpenGL resources in multithreaded app on GeForce GTX 1060
Looks like a driver bug, but I'm not sure ) Or maybe I do something wrong
In my application I use two different threads (and two shared contexts) to upload and render data.
The app sometimes crashes (probably when the workload is higher than…

simpetar
- 39
- 2
2
votes
3 answers
Check availability of resource used by another user
Building a web application.
User have access trough their browser to shared resources host on a server, however if UserA is already using Resource1, Resource1 should not be available to UserB until UserA release Resource1 or until a given amount of…

Erwan
- 1,055
- 1
- 12
- 26
2
votes
2 answers
Make a variable that is initialized by a function available to a function in multithreaded environment
So here is the problem I'm trying to solve, I'm programming in C.
We have a function that can initialize a struct for you.
typedef struct {
int val1;
int val2;
} custom_t;
custom_t init_custom() {
custom_t temp;
temp.val1 = 5;
temp.val2…

Coolmatt69
- 23
- 3
2
votes
1 answer
Process.start on network drive, ask for authentication
Considering this code:
Process process = new Process();
process.StartInfo.FileName = "explorer";
process.StartInfo.Arguments = "\\some_network_host\path";
process.Start();
I would like to connect to a shared resource and open the…

evg02gsa3
- 571
- 5
- 17