Development with openABK openABK development resources

Porting to a specific Platform

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.

Starting and ending Threads

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

Sleep Function

void AbkSleepMs (int nDelayMs);

This function sleeps for specified time.
nDelayMs: Delay in terms of milliseconds
Return value: -

Getting the own IP address

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.

Process Synchronization: Mutex

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()

Process Synchronization: Event

class CAbkEvent

Events int openABK are used to achieve the following:

  • Trigger an action across thread boundaries. For example one thread waits until it is allowed to perform a certain action. If another thread sets the event, the waiting thread continues running
  • Timing actions. This is used as a substitute for a sleep function. A thread waiting on a timed event can be released from waiting when the thread shall be terminated without having to wait until the time elapses

Use the one of the following suggestions, whichever your system supports:

Linux timed_event
Windows CreateEvent(), SetEvent(), ResetEvent(), WaitForSingleObject() CloseHandle()

Process Synchronization: SigleLock

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.