Offers some POSIX threads services that are not available on all platforms

Redefined classes

redef class Sys

pthreads :: extra $ Sys

The main class of the program.
redef abstract class Thread

pthreads :: extra $ Thread

Handle to a thread

All class definitions

redef class Sys

pthreads :: extra $ Sys

The main class of the program.
redef abstract class Thread

pthreads :: extra $ Thread

Handle to a thread
package_diagram pthreads::extra extra pthreads pthreads pthreads::extra->pthreads core core pthreads->core ...core ... ...core->core actors::actors actors actors::actors->pthreads::extra actors::agent_simulation agent_simulation actors::agent_simulation->actors::actors actors::chameneosredux chameneosredux actors::chameneosredux->actors::actors actors::fannkuchredux fannkuchredux actors::fannkuchredux->actors::actors actors::mandelbrot mandelbrot actors::mandelbrot->actors::actors actors::simple simple actors::simple->actors::actors actors::thread_ring thread_ring actors::thread_ring->actors::actors actors::agent_simulation... ... actors::agent_simulation...->actors::agent_simulation actors::chameneosredux... ... actors::chameneosredux...->actors::chameneosredux actors::fannkuchredux... ... actors::fannkuchredux...->actors::fannkuchredux actors::mandelbrot... ... actors::mandelbrot...->actors::mandelbrot actors::simple... ... actors::simple...->actors::simple actors::thread_ring... ... actors::thread_ring...->actors::thread_ring

Ancestors

module abstract_collection

core :: abstract_collection

Abstract collection classes and services.
module abstract_text

core :: abstract_text

Abstract class for manipulation of sequences of characters
module array

core :: array

This module introduces the standard array structure.
module bitset

core :: bitset

Services to handle BitSet
module bytes

core :: bytes

Services for byte streams and arrays
module circular_array

core :: circular_array

Efficient data structure to access both end of the sequence.
module codec_base

core :: codec_base

Base for codecs to use with streams
module codecs

core :: codecs

Group module for all codec-related manipulations
module collection

core :: collection

This module define several collection classes.
module core

core :: core

Standard classes and methods used by default by Nit programs and libraries.
module environ

core :: environ

Access to the environment variables of the process
module error

core :: error

Standard error-management infrastructure.
module exec

core :: exec

Invocation and management of operating system sub-processes.
module file

core :: file

File manipulations (create, read, write, etc.)
module fixed_ints

core :: fixed_ints

Basic integers of fixed-precision
module fixed_ints_text

core :: fixed_ints_text

Text services to complement fixed_ints
module flat

core :: flat

All the array-based text representations
module gc

core :: gc

Access to the Nit internal garbage collection mechanism
module hash_collection

core :: hash_collection

Introduce HashMap and HashSet.
module iso8859_1

core :: iso8859_1

Codec for ISO8859-1 I/O
module kernel

core :: kernel

Most basic classes and methods.
module list

core :: list

This module handle double linked lists
module math

core :: math

Mathematical operations
module native

core :: native

Native structures for text and bytes
module numeric

core :: numeric

Advanced services for Numeric types
module protocol

core :: protocol

module queue

core :: queue

Queuing data structures and wrappers
module range

core :: range

Module for range of discrete objects.
module re

core :: re

Regular expression support for all services based on Pattern
module ropes

core :: ropes

Tree-based representation of a String.
module sorter

core :: sorter

This module contains classes used to compare things and sorts arrays.
module stream

core :: stream

Input and output streams of characters
module text

core :: text

All the classes and methods related to the manipulation of text entities
module time

core :: time

Management of time and dates
module union_find

core :: union_find

union–find algorithm using an efficient disjoint-set data structure
module utf8

core :: utf8

Codec for UTF-8 I/O

Parents

module pthreads

pthreads :: pthreads

Main POSIX threads support and intro the classes Thread, Mutex and Barrier

Children

module actors

actors :: actors

Abstraction of the actors concepts

Descendants

module a_star-m

a_star-m

module agent_simulation

actors :: agent_simulation

a "Framework" to make Multi-Agent Simulations in Nit
module chameneosredux

actors :: chameneosredux

Example implemented from "The computer Language Benchmarks Game" - Chameneos-Redux
module fannkuchredux

actors :: fannkuchredux

Example implemented from "The computer Language Benchmarks Game" - Fannkuch-Redux
module mandelbrot

actors :: mandelbrot

Example implemented from "The computer Language Benchmarks Game" - Mandelbrot
module simple

actors :: simple

A very simple example of the actor model
module simple_simulation

actors :: simple_simulation

Using agent_simulation by refining the Agent class to make
module thread_ring

actors :: thread_ring

Example implemented from "The computer Language Benchmarks Game" - Thread-Ring
# Offers some POSIX threads services that are not available on all platforms
module extra is
	cflags "-pthread"
	ldflags "-pthread"
end

intrude import pthreads

in "C" `{
	// TODO protect with: #ifdef WITH_LIBGC
	#ifndef ANDROID
		#define GC_THREADS
		#include <gc.h>
	#endif
`}

redef extern class NativePthread
	fun cancel: Bool `{
		return pthread_cancel(*self);
	`}
end

redef class Thread
	# Cancel the execution of the thread
	fun cancel
	do
		if native == null then return
		native.cancel
		native = null
	end
end

# Does not return if the running thread is to be cancelled
fun test_cancel `{ pthread_testcancel(); `}

private extern class NativePthreadBarrier in "C" `{ pthread_barrier_t * `}
	new(count: Int) `{
		pthread_barrier_t *barrier = malloc(sizeof(pthread_barrier_t));
		int res = pthread_barrier_init(barrier, NULL, count);
		return barrier;
	`}

	fun destroy `{ pthread_barrier_destroy(self); `}

	fun wait `{ pthread_barrier_wait(self); `}
end
lib/pthreads/extra.nit:17,1--62,3