summaryrefslogtreecommitdiff
path: root/docs/tutorials/019/shmem.cpp
blob: d8f192daf0f89b2b7101336fabe88eeb305ef576 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

// $Id$

#include "shmem.h"

#if ! defined(ACE_LACKS_SYSV_SHMEM)
/*
  Set the available_ flag to zero & optionally initialize the buf_
  area.
*/
SharedData::SharedData(int _initialize)
    : available_(0)
{
    if( _initialize )
    {
        ACE_OS::sprintf(buf_,"UNSET\n");
    }
}

/*
  Write the process ID into the buffer.  This will prove to us that
  the data really is shared between the client and server.
*/
void SharedData::set(void)
{
    ACE_OS::sprintf(buf_,"My PID is (%d)\n",ACE_OS::getpid());
}

/*
  Display the buffer to the user
*/
void SharedData::show(void)
{
    ACE_DEBUG ((LM_INFO, "(%P|%t) Shared Data text is (%s)\n",
                buf_ ));
}

// Show flag
int SharedData::available(void)
{
    return available_;
}

// Set flag
void SharedData::available(int _available)
{
    available_ = _available;
}
#endif // ACE_LACKS_SYSV_SHMEM