i want to understand this -simple thread-safe wrapper for an array- inside out, where do i start?

Dec 11, 2012 at 9:53pm
i know basic c++ but the only word in
simple thread-safe wrapper for an array
i know is array

i would like to do this without installing a a library if i can help it, i downloaded c++11 and boost but i really don't know how to link things.

Dec 11, 2012 at 10:07pm
closed account (zb0S216C)
You can start by learning the terminology:-

Thread-Safe: Indicates that the implementation can handle simultaneous read/write operations by threads at any given time whilst avoiding dead-locks and/or race conditions. Note that a "dead-lock" is where two threads are waiting upon each other and a "race condition" is where two threads are trying to access the same resource at the same time (two people trying to get through one door at the same time).

Thread: A light-weight process (normally at user-level) that executes independently of the main process thread ("main( )") which created it. Threads are the core of multi-threading.

Wrapper: An implementation that provides an interface to another encapsulated implementation. The code below is an example of a wrapper.

1
2
3
4
5
6
7
struct ArrayWrapper
{
    int Array_[10];

    unsigned int Length( ) const;
    void Assign( int Index_, int Value_ );
};

Wazzak
Dec 11, 2012 at 11:02pm
so can i just straight up build this as though it was someting like a linked list or are there commands or libraries...i need a keyword that knows its running something dont i :/
Last edited on Dec 11, 2012 at 11:03pm
Dec 13, 2012 at 9:57am
closed account (zb0S216C)
Implementing the wrapper isn't difficult, but you may need to incorporate a library for the threads. Thing is, you may need to show your understanding of threads upon presentation of your wrapper. And no, there are no "keywords" for threads.

Wazzak
Dec 13, 2012 at 2:45pm
i downloaded c++11
how did you do that?

And yes C++11 supports keywords for thread:

http://en.cppreference.com/w/cpp/thread
Dec 17, 2012 at 6:49pm
i dont know how i did it or what it was that i downloaded, am really doubting myself now
Topic archived. No new replies allowed.