To ease porting, platform specific items are isolated in the ready C++ code. These items are held in the files Crossplatform.h and CrossPlatform.cpp. When porting to your specific system, make a copy of these files and adapt them to the target system.
ABK_THREAD_HANDLE AbkStartThread (void( __cdecl *start_address )(void *), void *pArgs);
This function starts a thread.
start_address: Thread function address
pArgs: Argument passed to the thread function
Return value: Handle of the thread or
ABK_INVALID_THREAD_HANDLE on error
void AbkSleepMs (int nDelayMs);
This function sleeps for specified time.
nDelayMs: Delay in terms of milliseconds
Return value: -
const std::string &AbkGetOwnIpAddress (void);
This function returns the IP address of the main Ethernet
adapter.
Return value: the IP address of the main Ethernet adapter in string
representation
The operation of openABK does not rely on the result of this function. It is
required for diagnostic purposes.
class CAbkMutex
openABK protects items with recursive mutexes. Such a mutex can be owned by one thread simultaneously. When a thread has already granted ownership, successive Lock() calls shall not block. They shall increment a lock counter. Unlock() shall decrement the counter and when the counter reached 0, ownership shall be released.
Use the one of the following suggestions, whichever your system supports:
Linux | recursive_mutex, lock(), unlock() |
Windows | CreateMutex(), WaitForSingleObject(), ReleaseMutex(), CloseHandle() |
std:: | class recursive_mutex, lock(), unlock() |
class CAbkEvent
Events int openABK are used to achieve the following:
Use the one of the following suggestions, whichever your system supports:
Linux | timed_event |
Windows | CreateEvent(), SetEvent(), ResetEvent(), WaitForSingleObject() CloseHandle() |
class CAbkSingleLock
The single lock object is used to code a reliable access to protected sections. When the single lock object falls out of scope, its mutex is released automatically. This paradigm prevents forgetting to unlock a mutex when returning from a function.
Usually, when porting, you do not have to modify CAbkSingleLock since it relies completely on CAbkMutex.