POSIX Threads support

The threads can be manipulated and synchronized using the classes Thread, Mutex and Barrier.

This group also provides two optional modules with thread-safe collections:

  • redef_collections redefines existing collection to make them thread-safe. This incures a small overhead in all usage of the redefined collections.
  • concurrent_collections intro new thread-safe collections.

Theses services are implemented using the POSIX threads.

You can also use the is threaded annotation on methods, which makes them run on their own thread. Methods with self calls are not supported.

A method or function annotated with is threaded has its return value changed during compilation. You will get a subclass of Thread, even if there wasn't a return value before. You can know if the threaded method is done with the is_done boolean from Thread. A call to the join method will block the execution until the threaded method is done, or immediatly return if it's already done. join will return an object typed with the orginial return type, or null if there wasn't.

Known limitations:

  • Most services from the Nit library are not thread-safe. You must manage your own mutex to avoid conflicts on shared data.
  • FFI's global references are not thread-safe.

For more information:

  • See: man pthreads
  • See: examples/concurrent_array_and_barrier.nit
  • See: ̀ examples/threaded_example.nit`

All subgroups and modules

module concurrent_collections

pthreads :: concurrent_collections

Introduces thread-safe concurrent collections
module extra

pthreads :: extra

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

pthreads :: pthreads

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

pthreads :: redef_collections

Redef some basic collections to be thread-safe
module threadpool

pthreads :: threadpool

Introduces a minimal ThreadPool implementation using Tasks
package_diagram pthreads\> pthreads core core pthreads\>->core actors actors actors->pthreads\> app app app->pthreads\> libevent libevent libevent->pthreads\> nitcorn nitcorn nitcorn->pthreads\> nitcorn->libevent nlp nlp nlp->pthreads\> popcorn popcorn popcorn->pthreads\> pthreads\>examples\> examples pthreads\>examples\>->pthreads\> android android android->app gamnit gamnit gamnit->app ios ios ios->app linux linux linux->app android... ... android...->android gamnit... ... gamnit...->gamnit ios... ... ios...->ios linux... ... linux...->linux nitcorn... ... nitcorn...->nitcorn github github github->popcorn nitc nitc nitc->popcorn github... ... github...->github nitc... ... nitc...->nitc

Ancestors

group codecs

core > codecs

Group module for all codec-related manipulations
group collection

core > collection

This module define several collection classes.
group text

core > text

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

Parents

group core

core

Nit common library of core classes and methods

Children

group actors

actors

Nit Actor Model
group app

app

app.nit, a framework for portable applications
group libevent

libevent

Low-level wrapper around the libevent library to manage events on file descriptors
group nitcorn

nitcorn

Lightweight framework for Web applications development
group nlp

nlp

Nit wrapper for Stanford CoreNLP
group popcorn

popcorn

Popcorn

Descendants

group agent_simulation

actors > examples > agent_simulation

a "Framework" to make Multi-Agent Simulations in Nit
group android

android

Android platform support and APIs
group api

nitc > doc > api

Components required to build a web server about the nit model.
group bundle

android > bundle

A mapping class of String to various value types used by the
group catalog

nitc > catalog

Basic catalog generator for Nit packages
group commands

nitc > doc > commands

group compiler

nitc > compiler

Compilation to C
group compiler_ffi

nitc > compiler > compiler_ffi

Full FFI support for the compiler
group depth

gamnit > depth

gamnit depth, a framework to create portable 3D games in Nit.
group doc

nitc > doc

group dynamic_loading_ffi

nitc > interpreter > dynamic_loading_ffi

This group implement a partial support for the Nit FFI in the interpreter.
group egl

egl

Interface between rendering APIs (OpenGL, OpenGL ES, etc.) and the native windowing system.
group examples

nlp > examples

group examples

ios > examples

group examples

app > examples

group fannkuchredux

actors > examples > fannkuchredux

Example implemented from "The computer Language Benchmarks Game" - Fannkuch-Redux
group ffi

nitc > ffi

Full FFI support, independent of the compiler
group flat

gamnit > flat

Simple API for 2D games, built around Sprite and App::update
group frontend

nitc > frontend

Collect and orchestration of main frontend phases
group gamnit

gamnit

Portable game and multimedia framework for Nit
group github

github

Nit wrapper for Github API
group glesv2

glesv2

OpenGL graphics rendering library for embedded systems, version 2.0
group intent

android > intent

Services allowing to launch activities and start/stop services using
group interpreter

nitc > interpreter

Interpretation of Nit programs
group ios

ios

iOS support for app.nit
group linux

linux

Implementation of app.nit for the Linux platform
group mandelbrot

actors > examples > mandelbrot

Example implemented from "The computer Language Benchmarks Game" - Mandelbrot
group metrics

nitc > metrics

Various statistics about Nit models and programs
group model

nitc > model

The meta model of Nit programs
group modelize

nitc > modelize

Create a model from nit source files
group nitc

nitc

Nit compiler and tools
group nitni

nitc > nitni

Native interface related services (used underneath the FFI)
group notification

android > notification

Services to show notification in the Android status bar
group parser

nitc > parser

Parser and AST for the Nit language
group platform

nitc > platform

Platform system, used to customize the behavior of the compiler.
group saf

nitc > saf

Nit Static Analysis Framework.
group semantize

nitc > semantize

Process bodies of methods in regard with the model.
group service

android > service

Android service support for app.nit centered around the class Service
group shared_preferences

android > shared_preferences

Services allowing to save and load datas to internal android device
group simple

actors > examples > simple

A very simple example of the actor model
group src

android > examples > src

group src

nitcorn > examples > src

group static

nitc > doc > static

Nitdoc generation framework
group term

nitc > doc > term

group testing

nitc > testing

Test unit generation and execution for Nit.
group ui

android > ui

Views and services to use the Android native user interface
group ui

ios > ui

Implementation of app::ui for iOS
group uml

nitc > uml

Group head module for UML generation services
group virtual_gamepad

gamnit > virtual_gamepad

Virtual gamepad mapped to keyboard keys for quick and dirty mobile support
group vm

nitc > vm

Entry point of all vm components