Skip to content

Commit

Permalink
Gen/javadoc (#35)
Browse files Browse the repository at this point in the history
* Added Javadoc

* Remove commented code

---------

Co-authored-by: Peter Lawrey <peter.lawrey@chronicle.software>
  • Loading branch information
keiran-lawrey and peter-lawrey authored Jun 14, 2024
1 parent bfaa7af commit ea86882
Show file tree
Hide file tree
Showing 27 changed files with 946 additions and 74 deletions.
37 changes: 37 additions & 0 deletions src/main/java/net/openhft/posix/ClockId.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,61 @@
package net.openhft.posix;

/**
* This enum represents the different clock IDs used in clock operations.
* It defines the various clocks that can be used for timing and synchronization purposes.
*/
public enum ClockId {
// The system-wide real-time clock
CLOCK_REALTIME(0),

// The monotonic clock, which cannot be set and represents monotonic time since some unspecified starting point
CLOCK_MONOTONIC(1),

// The clock measuring the CPU time consumed by the process
CLOCK_PROCESS_CPUTIME_ID(2),

// The clock measuring the CPU time consumed by the thread
CLOCK_THREAD_CPUTIME_ID(3),

// The raw monotonic clock, without NTP adjustments
CLOCK_MONOTONIC_RAW(4),

// The system-wide real-time clock, but faster and less accurate
CLOCK_REALTIME_COARSE(5),

// The coarse monotonic clock, but faster and less accurate
CLOCK_MONOTONIC_COARSE(6),

// The monotonic clock that includes time spent in suspend
CLOCK_BOOTTIME(7),

// The system-wide real-time clock used to set alarms
CLOCK_REALTIME_ALARM(8),

// The boot-time clock used to set alarms
CLOCK_BOOTTIME_ALARM(9),

// The SGI cycle counter
CLOCK_SGI_CYCLE(10);

// The integer value representing the clock ID
private final int value;

/**
* Constructor for ClockId.
*
* @param value The integer value representing the clock ID
*/
ClockId(int value) {
this.value = value;
}

/**
* This method is a getter for the value instance variable.
* It returns the current integer value of this ClockId object.
*
* @return The current integer value of this ClockId object
*/
public int value() {
return value;
}
Expand Down
41 changes: 26 additions & 15 deletions src/main/java/net/openhft/posix/LockfFlag.java
Original file line number Diff line number Diff line change
@@ -1,43 +1,54 @@
package net.openhft.posix;

/**
* This enum represents the different flags for file locking (lockf) operations.
* It defines the operations to be performed on file locks, such as locking, unlocking, and testing locks.
*/
public enum LockfFlag {
/**
* Unlock the indicated section of the file. This may cause
* a locked section to be split into two locked sections.
* Unlock the indicated section of the file.
* This may cause a locked section to be split into two locked sections.
*/
F_ULOCK(0),

/**
* Set an exclusive lock on the specified section of the
* file. If (part of) this section is already locked, the
* call blocks until the previous lock is released. If this
* section overlaps an earlier locked section, both are
* merged. File locks are released as soon as the process
* holding the locks closes some file descriptor for the
* file. A child process does not inherit these locks.
* Set an exclusive lock on the specified section of the file.
* If (part of) this section is already locked, the call blocks until the previous lock is released.
* If this section overlaps an earlier locked section, both are merged.
* File locks are released as soon as the process holding the locks closes some file descriptor for the file.
* A child process does not inherit these locks.
*/
F_LOCK(1),

/**
* Same as F_LOCK but the call never blocks and returns an
* error instead if the file is already locked.
* Same as F_LOCK but the call never blocks and returns an error instead if the file is already locked.
*/
F_TLOCK(2),

/**
* Test the lock: return 0 if the specified section is
* unlocked or locked by this process; return -1, set errno
* to EAGAIN (EACCES on some other systems), if another
* process holds a lock.
* Test the lock: return 0 if the specified section is unlocked or locked by this process;
* return -1, set errno to EAGAIN (EACCES on some other systems), if another process holds a lock.
*/
F_TEST(3);

// The integer value representing the lockf flag
final int value;

/**
* Constructor for LockfFlag.
*
* @param value The integer value representing the lockf flag
*/
LockfFlag(int value) {
this.value = value;
}

/**
* This method is a getter for the value instance variable.
* It returns the current integer value of this LockfFlag object.
*
* @return The current integer value of this LockfFlag object
*/
public int value() {
return value;
}
Expand Down
84 changes: 67 additions & 17 deletions src/main/java/net/openhft/posix/MAdviseFlag.java
Original file line number Diff line number Diff line change
@@ -1,29 +1,79 @@
package net.openhft.posix;

/**
* This enum represents the different flags for memory advice (madvise) operations.
* It defines the advice to be given to the kernel about the intended usage pattern of memory.
*/
public enum MAdviseFlag {
MADV_NORMAL(0), /* No further special treatment. */
MADV_RANDOM(1), /* Expect random page references. */
MADV_SEQUENTIAL(2), /* Expect sequential page references. */
MADV_WILLNEED(3), /* Will need these pages. */
MADV_DONTNEED(4), /* Don't need these pages. */
MADV_FREE(8), /* Free pages only if memory pressure. */
MADV_REMOVE(9), /* Remove these pages and resources. */
MADV_DONTFORK(10), /* Do not inherit across fork. */
MADV_DOFORK(11), /* Do inherit across fork. */
MADV_MERGEABLE(12), /* KSM may merge identical pages. */
MADV_UNMERGEABLE(13), /* KSM may not merge identical pages. */
MADV_HUGEPAGE(14), /* Worth backing with hugepages. */
MADV_NOHUGEPAGE(15), /* Not worth backing with hugepages. */
MADV_DONTDUMP(16), /* Explicity exclude from the core dump, overrides the coredump filter bits. */
MADV_DODUMP(17), /* Clear the MADV_DONTDUMP flag. */
MADV_WIPEONFORK(18), /* Zero memory on fork, child only. */
MADV_KEEPONFORK(19); /* Undo MADV_WIPEONFORK. */
// No further special treatment
MADV_NORMAL(0),

// Expect random page references
MADV_RANDOM(1),

// Expect sequential page references
MADV_SEQUENTIAL(2),

// Will need these pages
MADV_WILLNEED(3),

// Don't need these pages
MADV_DONTNEED(4),

// Free pages only if memory pressure
MADV_FREE(8),

// Remove these pages and resources
MADV_REMOVE(9),

// Do not inherit across fork
MADV_DONTFORK(10),

// Do inherit across fork
MADV_DOFORK(11),

// KSM may merge identical pages
MADV_MERGEABLE(12),

// KSM may not merge identical pages
MADV_UNMERGEABLE(13),

// Worth backing with hugepages
MADV_HUGEPAGE(14),

// Not worth backing with hugepages
MADV_NOHUGEPAGE(15),

// Explicitly exclude from the core dump, overrides the coredump filter bits
MADV_DONTDUMP(16),

// Clear the MADV_DONTDUMP flag
MADV_DODUMP(17),

// Zero memory on fork, child only
MADV_WIPEONFORK(18),

// Undo MADV_WIPEONFORK
MADV_KEEPONFORK(19);

// The integer value representing the madvise flag
final int value;

/**
* Constructor for MAdviseFlag.
*
* @param value The integer value representing the madvise flag
*/
MAdviseFlag(int value) {
this.value = value;
}

/**
* This method is a getter for the value instance variable.
* It returns the current integer value of this MAdviseFlag object.
*
* @return The current integer value of this MAdviseFlag object
*/
public int value() {
return value;
}
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/net/openhft/posix/MMapFlag.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
package net.openhft.posix;

/**
* This enum represents the different flags for mmap operations.
* It defines the flags for memory mapping operations, including shared and private mappings.
*/
public enum MMapFlag {
// Memory mapping to be shared with other processes
SHARED(1),

// Memory mapping to be private to the process
PRIVATE(2);

// The integer value representing the mmap flag
private int value;

/**
* Constructor for MMapFlag.
*
* @param value The integer value representing the mmap flag
*/
MMapFlag(int value) {
this.value = value;
}

/**
* This method is a getter for the value instance variable.
* It returns the current integer value of this MMapFlag object.
*
* @return The current integer value of this MMapFlag object
*/
public int value() {
return value;
}
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/net/openhft/posix/MMapProt.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,46 @@
package net.openhft.posix;

/**
* This enum represents the different memory protection options for mmap.
* It defines the protection levels for memory mapping operations, including read, write, execute, and none.
*/
public enum MMapProt {
// Memory protection to allow read access
PROT_READ(1),

// Memory protection to allow write access
PROT_WRITE(2),

// Memory protection to allow both read and write access
PROT_READ_WRITE(3),

// Memory protection to allow execute access
PROT_EXEC(4),

// Memory protection to allow both execute and read access
PROT_EXEC_READ(5),

// Memory protection to allow no access
PROT_NONE(8);

// The integer value representing the memory protection level
final int value;

/**
* Constructor for MMapProt.
*
* @param value The integer value representing the memory protection level
*/
MMapProt(int value) {
this.value = value;
}

/**
* This method is a getter for the value instance variable.
* It returns the current integer value of this MMapProt object.
*
* @return The current integer value of this MMapProt object
*/
public int value() {
return value;
}
Expand Down
27 changes: 21 additions & 6 deletions src/main/java/net/openhft/posix/MSyncFlag.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,43 @@
package net.openhft.posix;

/**
* This enum represents the different flags for memory synchronization (msync) operations.
* It defines the flags used to control the behavior of memory synchronization operations.
*/
public enum MSyncFlag {
//#define MS_ASYNC 1 /* sync memory asynchronously */
/**
* sync memory asynchronously
* Sync memory asynchronously.
*/
MS_ASYNC(1),
//#define MS_INVALIDATE 2 /* invalidate the caches */

/**
* invalidate the caches
* Invalidate the caches.
*/
MS_INVALIDATE(2),
//#define MS_SYNC 4 /* synchronous memory sync */

/**
* synchronous memory sync
* Synchronous memory sync.
*/
MS_SYNC(4);

// The integer value representing the msync flag
private final int value;

/**
* Constructor for MSyncFlag.
*
* @param value The integer value representing the msync flag
*/
MSyncFlag(int value) {
this.value = value;
}

/**
* This method is a getter for the value instance variable.
* It returns the current integer value of this MSyncFlag object.
*
* @return The current integer value of this MSyncFlag object
*/
public int value() {
return value;
}
Expand Down
Loading

0 comments on commit ea86882

Please sign in to comment.