Changeset 312 in pacpusframework for trunk/src/PacpusTools


Ignore:
Timestamp:
07/28/14 16:11:30 (10 years ago)
Author:
Marek Kurdej
Message:

ComponentBase: added addParameter.

Location:
trunk/src/PacpusTools/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/PacpusTools/src/PosixShMem.cpp

    r162 r312  
    6666        result = true;
    6767    }
    68    
     68
    6969    /////////////////////////////////////////
    7070    if (result) {
  • trunk/src/PacpusTools/src/SharedMemory.cpp

    r303 r312  
    6262            << ". Message: " << (const char *) lpMsgBuf
    6363            << ". Program will exit"
    64             ); 
    65         ::exit(-1); 
     64            );
     65        ::exit(-1);
    6666    }
    6767
    6868    // create the event - autoreset mode
    69     event_ = CreateEvent(NULL, false, false, eventName.c_str()); 
     69    event_ = CreateEvent(NULL, false, false, eventName.c_str());
    7070
    7171    // lock the semaphore and try to create the shared memory
    72     lockMemory(); 
    73     shMemHandle_ = CreateFileMapping(INVALID_HANDLE_VALUE, NULL,        PAGE_READWRITE, 0, size, name); 
     72    lockMemory();
     73    shMemHandle_ = CreateFileMapping(INVALID_HANDLE_VALUE, NULL,        PAGE_READWRITE, 0, size, name);
    7474    if (shMemHandle_ == NULL) {
    7575        LOG_FATAL("cannot create shared memory segment '" << name << "'"
    7676            << ". Error: " << GetLastError()
    7777            << ". Program will exit"
    78             ); 
     78            );
    7979        ::exit(-1);
    8080    }
    8181
    8282    // Map the memory to a local pointer
    83     shMem_ = MapViewOfFile(shMemHandle_, FILE_MAP_ALL_ACCESS, 0, 0, 0); 
     83    shMem_ = MapViewOfFile(shMemHandle_, FILE_MAP_ALL_ACCESS, 0, 0, 0);
    8484    if (shMem_ == NULL) {
    8585        LOG_FATAL("cannot map the view of file of the shared memory segment '" << name << "'"
    8686            << ". Error: " << GetLastError()
    8787            << ". Program will exit"
    88             ); 
     88            );
    8989        ::exit(-1);
    9090    }
    9191
    92     LOG_INFO("created Win32 shared memory '" << name << "'"); 
     92    LOG_INFO("created Win32 shared memory '" << name << "'");
    9393
    9494    unlockMemory();
     
    135135        result = true;
    136136    }
    137    
     137
    138138    /////////////////////////////////////////
    139139    if (result) {
     
    168168    LOG_TRACE("destructor");
    169169#if PACPUS_OS_WINDOWS
    170     // free the semaphore 
    171     CloseHandle(semaphore_); 
    172     UnmapViewOfFile(shMem_); 
    173     CloseHandle(shMemHandle_); 
     170    // free the semaphore
     171    CloseHandle(semaphore_);
     172    UnmapViewOfFile(shMem_);
     173    CloseHandle(shMemHandle_);
    174174#elif PACPUS_OS_UNIX
    175175    // detach this process from the shared memory
     
    186186#if PACPUS_OS_WINDOWS
    187187    if (timeout == 0) {
    188         timeout = INFINITE; 
    189     }
    190 
    191     DWORD status = 0; 
    192     status = WaitForSingleObject(event_, timeout); 
     188        timeout = INFINITE;
     189    }
     190
     191    DWORD status = 0;
     192    status = WaitForSingleObject(event_, timeout);
    193193
    194194    if (status == WAIT_OBJECT_0) {
    195         return true; 
     195        return true;
    196196    } else {
    197         return false; 
     197        return false;
    198198    }
    199199#elif PACPUS_OS_UNIX
     
    209209    void* shMem;
    210210#if PACPUS_OS_WINDOWS
    211     lockMemory(); 
     211    lockMemory();
    212212#endif
    213213    shMem = shMem_;
    214214#if PACPUS_OS_WINDOWS
    215     unlockMemory(); 
     215    unlockMemory();
    216216#endif
    217217    return shMem;
     
    221221{
    222222    lockMemory();
    223     memcpy(dst, shMem_, size); 
     223    memcpy(dst, shMem_, size);
    224224    unlockMemory();
    225225}
     
    228228{
    229229#if PACPUS_OS_WINDOWS
    230     return event_; 
     230    return event_;
    231231#elif PACPUS_OS_UNIX
    232232    LOG_TRACE("no event identifier");
     
    241241    LOG_TRACE("writing " << size << " bytes to shared memory at offset " << offset);
    242242#if PACPUS_OS_WINDOWS
    243     lockMemory(); 
     243    lockMemory();
    244244    //unsigned long * dest = (unsigned long *)shMem_ + offset;
    245245    char * dest = (char *)shMem_ + offset;
    246     //printf("adresses : shm : %x  dest : %x   offset : %x \n",shMem_, dest, offset); 
     246    //printf("adresses : shm : %x  dest : %x   offset : %x \n",shMem_, dest, offset);
    247247    memcpy(dest, data, size);
    248248    unlockMemory();
    249     SetEvent(event_); 
     249    SetEvent(event_);
    250250#elif PACPUS_OS_UNIX
    251251    lockMemory();
     
    267267{
    268268#if PACPUS_OS_WINDOWS
    269     WaitForSingleObject(semaphore_, INFINITE); 
     269    WaitForSingleObject(semaphore_, INFINITE);
    270270#elif PACPUS_OS_UNIX
    271271    BOOST_ASSERT(memory_);
     
    279279{
    280280#if PACPUS_OS_WINDOWS
    281     ReleaseSemaphore(semaphore_, 1, NULL); 
     281    ReleaseSemaphore(semaphore_, 1, NULL);
    282282#elif PACPUS_OS_UNIX
    283283    BOOST_ASSERT(memory_);
Note: See TracChangeset for help on using the changeset viewer.