Skip to content
/ BPjs Public
forked from bThink-BGU/BPjs

Environment for running behavioral programs written in Javascript.

License

Notifications You must be signed in to change notification settings

szegedi/BPjs

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

BPjs: A Javascript-based Behavioral Programming Runtime.

This repository contains a javascript-based BP library.

Build Status Coverage Status Maven Central Documentation Status JavaDocs

License

  • BPjs is open sourced under the MIT license. If you use it in a system, please provide a link to this page somewhere in the documentation/system about section.
  • BPjs uses the Mozilla Rhino Javascript engine. Project page and source code can be found here.

Getting BPjs

  • For Maven projects: Add BPjs as dependency. Note that the version number changes.
<dependencies>
    ...
    <dependency>
        <groupId>com.github.bthink-bgu</groupId>
        <artifactId>BPjs</artifactId>
        <version>0.8.6</version>
    </dependency>
    ...
</dependencies>

Documentation

Change log for the BPjs library.

2018-02-25

  • โฌ†๏ธ VisitedStateStore Adds a clear() method.
  • ๐Ÿ› DfsBProgramVerifier instances can now be re-used.

2018-01-24

  • โฌ†๏ธ Improved hashing algorithm on BThreadStateVisitedNodeStore.
  • โœจ Transient caching of thread state in BThreadSyncSnapshots. This improves verification performance, with low memory cost.
  • ๐Ÿ› Removed visited state stores that took incoming state into consideration.
  • ๐Ÿ”„ More mazes in the Mazes example.

2018-01-18

  • ๐Ÿ› Fixed a crash where program with failed assertions were intermittently crashing.

2018-01-17

  • ๐Ÿ› Verifier now correctly identifies deadlock as a state where there are requested events, but they are all blocked (formerly it just looked for the existence of b-threads).

2018-01-12

  • ๐Ÿ› โœจ Refactored analysis code, removing the invalid (easy to understand, but invalid) PathRequirement based analysis, and using only b-thread now. This design is much cleaner, as it uses less concepts. Also moves us towards "everything is a b-thread" world.
  • โœจ Added tests to demonstrate the various states a verification can end in.
  • ๐Ÿ› Verifiers and runners terminate their threadpools when they are done using them.

2018-01-11

  • โœจ During forward execution, b-threads can halt execution using bp.ASSERT(boolean, text).
  • โฌ†๏ธ Refactored the engine tasks to support raising assertions. Reduced some code duplication in the way.
  • โฌ†๏ธ Thread pools executing b-threads are now allocated per-executor/verifier (as opposed to using a single static pool).

2017-12-28

  • โฌ†๏ธ Re-arranged package structure, duplicate and ambiguous packages merged. We now have a clean model/execution/analysis division.
  • ๐Ÿ› Fixed an equality bug in OrderedSet.

2017-12-22

  • ๐Ÿ› BSyncStatements now retain information about the b-thread that created them.
  • โฌ†๏ธ Now using a single ExecutorService for the entire JVM (OK, per class-loader). This makes runtime more efficient, resource-wise.
  • ๐Ÿ”„ Using cached thread execution pool instead of the fork-join one (the former seems to make more sense in a BP context).
  • โฌ†๏ธ The Java threads executing the b-threads now have specific names: bpjs-executor-N (where N is a number starting at 1).
  • โœจ New method: bp.getJavaThreadName: Returns the name of the Java thread executing the b-thread while this method was called.
  • ๐ŸŽ‰ Some changes in this version were requested by actual users. ๐ŸŽ‰
  • โœจ Documentation updated to mention verification (full-length text to be added post-paper).
  • ๐Ÿ› BThreadJSProxy.get/setBthread updated to use capital T, like the resp fo the code.
  • ๐Ÿ”„ Test clean-up
  • ๐Ÿ”„ Documentation clean-up

2017-11-24

  • โœจ BProgram allows appending and prepending source code programmatically, using appendSource and prependSource. These can be used to add environment simulation without touching the simulated model. Or just to act as includes, e.g. for common set-ups.
  • โœจ Added new class: PathRequirements, to hold path requirements that do not require state (e.g. "no deadlock").
  • โœจ DfsBProgramVerifier now has a "debug mode" (set/get via get/isDebugMode). On debug mode, it prints verbose information to System.out.
  • โœจ Added new class: BThreadStateVisitedNodeStore, looks only into the states of the b-threads when deciding whether a search node was already visited or not.
  • ๐Ÿ› InMemoryEventLoggingListener cleans its event log when a run begins, so it can be reused for multiple runs.
  • ๐Ÿ”„ Reduced method accessibility in BProgram, so subclassers have harder time getting into trouble.
  • :put_trash_in_its_place: BProgramListener renamed to BProgramRunnerListener, since that is the object it listens to.
  • :put_trash_in_its_place: NoDeadlock class deleted. Use PathRequirements.NO_DEADLOCK instead.
  • โœจ PathRequirements.ACCEPT_ALL, is a new requirement that's always true. Useful for scanning a program state space.

2017-11-23

  • โฌ†๏ธ DfsProgramVerifier uses FullVisitedNodeStore by default (preferring correctness over speed in the default case).
  • โฌ†๏ธ Updated the Dining Philosopher example to use advanced features. Also added it as a unit test.
  • ๐Ÿšฎ Removed validation package.
  • โœจ ContinuationProgramState correctly captures updated variable values. ๐ŸŽ‰

2017-11-02

  • โœจ the DfsBProgramVerifier is now accepting requirement objects over execution paths, instead of the hard-coded deadlock check.
  • โœจ new PathRequirement class. Requirements are passed to the verifiers for making sure the program conforms to them. Two implementation already present:
    • NoDeadlock Breakes when there's a deadlock
    • EventNotPresent Breaks when the last event in the ongoing path is a member of a given event set.
  • โœจ the DfsBProgramVerifier is now using listener architecture for reporting progress.
  • โœจ new event set from bp: bp.allExcept(es).
  • โฌ†๏ธ Efficient path stack implementation for BfsBProgramVerifier (no copying, reversal, etc.)
  • โฌ†๏ธ Mazes.java Updates to fully use the new verifier features

2017-10-30

  • โฌ†๏ธ Re-created program state cloning based on code from @szegedi. Cloning is now faster, more efficient, and can handle storage of events.

2017-10-16

  • โœจ New base class for implementing event selection strategies.
  • โœจ OrderedEventSelectionStrategy - A new event selection strategy that honors the order in which events are requested by a given b-thread.
  • โœจ PrioritizedBThreadsEventSelectionStrategy - A new event selection strategy that can assign priorities to b-threads.
  • โœจ PrioritizedBSyncEventSelectionStrategy - A new event selection strategy that allows b-threads to add priority to their bsyncs.
  • โฌ†๏ธ LoggingEventSelectionStrategyDecorator also logs selectable events
  • โฌ†๏ธ BProgram acts nicer when it has a null event selection strategy.

2017-09-10

  • โœจ Updated to Rhino 1.7.7.2.

2017-08-18

  • โœจ Initial verification added. DfsBProgramVerifier scans the states of a BProgram using DFS, and can return traces where there are no selectable events.

2017-08-06

  • โœจ Added a class to compare continuations (base for comparing snapshots).

2017-07-05

  • โœจ bsync now has an extra parameter, allowing b-threads to pass hinting data to custom EventSelectionStrategys.
  • ๐Ÿ”„ Moved event selection strategy to BProgram.
  • โœจ Added a mechanism to log the BProgramState at sync points.

2017-06-08

  • โœจ Added documentation for embedding BPjs programs in larger Java apps.

2017-05-16

  • โœจ README includes a more prominent reference to the documentation.

2017-05-10

  • โœจ Added an adapter class for BProgramListener.
  • ๐Ÿ› Fixed issues with adding objects to the program's scope.

2017-04-08

  • ๐Ÿšฎ Cleaned up the BProgramRunner-BProgram-BProgramSyncSnapshot trio such that listeners don't have to be passed around between them.
  • โœจ Cloning of BProgramSyncSnapshot ready. This is the basis for search.

2017-03-22

  • โœจ New architecture: Running logic moved from BProgram to BProgramRunner - ongoing.
  • โœจ BProgramListeners notified before BPrograms are started.
  • ๐Ÿ› Fixed a bug where dynamically added b-threads that were added by other dynamically added b-threads would run one cycle too late.
  • ๐Ÿ› Fixed a bug where external events enqueued from top-level JS code where ignored.

2017-03-21

  • โœจ New architecture: Running logic moved from BProgram to BProgramRunner. This will help implementing search.
  • โœจ BProgramListeners notified when a b-thread runs to completion.
  • โœจ bp.getTime() added.
  • โœจ Updated tutorial now includes the bp object.

2017-03-15

  • ๐Ÿšฎ Simplified the examples test package.
  • ๐Ÿšฎ all and none are now only available via bp.
  • ๐Ÿ”„ cleaner scope structure..

2017-03-14

  • ๐Ÿ”„ Internal method name clean-ups.
  • ๐Ÿšฎ Removed unneeded initializations.
  • ๐Ÿ› Program and bthread scopes are treated as scopes rather than prototypes.
  • โœจ B-Thread scope games eliminated ๐ŸŽ‰. Dynamic b-thread addition is now possible from within loops etc. Tutorial updated.
  • โœจ More tests.

2017-03-02

  • โœจ bp.random added.
  • ๐Ÿ”„ Documentation updates
  • โœจ Added java accessors for putting and getting variables in the JS program
  • ๐Ÿ”„ fat.jar is now uber.jar.

2017-02-03

  • โœจ the standard .jar file now contains only BPjs, and no dependencies. Fat jar (the jar that includes dependencies) is available via the releases tab.

2017-02-02

  • ๐Ÿ”„ Events class renamed to EventSets. Some cleanup.
  • ๐Ÿ”„ emptySet is now none.
  • ๐Ÿ”„ all and emptySet are now available to BPjs code via bp.all and bp.none. This is to prevent name collisions with client code.
  • ๐Ÿ› Fixed an issue with the logger, where logging levels were ignored.
  • โœจ Log level can be set by BPjs code, using bp.log.setLevel(l). l is one of Warn, Info, Fine.

2017-01-16

  • โœจ Updated documentation to refer to Maven Central
  • ๐Ÿ› RunFile re-reads files from file system again.
  • ๐Ÿ”„ More dead code removal.

2017-01-14

This release in focused on better BPjs-programmer experience and getting the code into a maven-central quality grade.

  • ๐Ÿ› Fixing Javadoc references.
  • ๐Ÿšฎ Positional bsync removed.
  • โœจ Better error reporting on event sets defined in JavaScript.
  • โœจ Better error reports for generic JS errors.
  • โœจ Added StringBProgram: a new class for running BPjs code from a String (rather than a resource or a file).

2017-01-13

  • โœจ Adding a BThread is idempotent. Previously, if a BThread was added twice, it would run twice with unexpected results.
  • โœจ Basic engine exceptions, plus a friendlier error message when calling bsync outside of a BThread.
  • ๐Ÿ”„ More Javadocs and code cleanup (mostly dead code removal).

2017-01-12

  • โœจ License (MIT)
  • โœจ Preparations for Maven Central
  • ๐Ÿ”„ More Javadocs and code cleanup.

2017-01-05

  • โœจ RunFile can now accept multiple BPjs files for input, and runs them as a single BProgram. It also has improved help text.

2017-01-03

  • โœจ Added continuous code coverage with Coveralls.io (Thanks guys!).
  • โœจ Improved test coverage.

2017-01-02

  • โœจ Added continuous testing with Travis-CI (Thanks guys!).
  • ๐ŸŽ‰ Moved from native NetBeans to maven project ๐ŸŽ‰ ๐ŸŽ‰ โœจ
  • ๐Ÿ› Various small issues fixed thanks to static analysis (and NetBeans' Code Inspection tool).
  • ๐Ÿ”„ Moved to canonical package structure (il.ac.bgu.cs.bp.*).

2017-01-01

  • โœจ Re-arranged code to minimize amount of Context.enter-Context.exit pairs (~x5 performance factor!)
  • โœจ Simplified mechanism for handling event selection in BProgram. Replaced a complex Visitor pattern with Java8's Optional.
  • ๐Ÿ”„ Improved efficiency for external events handling.
  • โœจ More tests for SimpleEventSelectionStrategy.
  • โœจ More documentation.
  • โœจ Better error messages.
  • ๐Ÿšฎ Removed unused code from BProgram.
  • ๐Ÿšฎ Removed non-serializable Optional from fields.

2016-12-31

  • ๐Ÿšฎ Removed bpjs from JS scope. Programs must use bp now.
  • ๐Ÿšฎ Polished the interface for adding BThreads to a program: 1 method instead of 3.
  • ๐Ÿ› Fixed an issue where external events were re-ordered while checking for daemon mode termination.
  • ๐Ÿ› A BProgram now quits when there are no more BThreads, even if there are enqueued external events.
  • ๐Ÿ› Fixed typos in error messages.
  • ๐Ÿ”„ Reduces method accessibility to minimum (nothing is public unless it has to be).
  • โœจ More documentation.

2016-12-16

  • โœจ A class for running bpjs files.
  • ๐Ÿ‘ Efficient use of Context, so that we don't open and exit it all the time.
  • ๐Ÿšฎ More removal of more unused code. We now have less unused code. Less is more, especially with unused code.

2016-12-11

  • ๐Ÿ”„ breakUpon is now interrupt. This leaves breakUpon to be later used as a language construct rather than a bsync parameter.

2016-12-05

  • ๐Ÿšฎ โœจ ๐Ÿ˜ Big refactoring and clean-up towards enabling search. BThreads removed from engine - main new concept is that an execution of a BThread is a series of BThreadSyncSnapshot, advanced/connected by BPEngineTasks. A BProgram is an execution environment for multiple BThreads (plus some state and management code).

2016-09-18

  • ๐Ÿ› breakUpon handlers are evaluated in the BThread's context, rather than in the BProgram one.

2016-09-13

Client code / Javascript

  • โœจ Updated the logging mechanism from global, single level to 3-level. Code change required: bplog("hello") -> bp.log.info("hello). Also supports warn and fine.
  • ๐Ÿšฎ bpjs is deprecated (but still works). Please use bp now.
  • ๐Ÿšฎ positional bsync deprecated (but still works). Please use the named-argument variant bsync({request:....}).
  • ๐Ÿšฎ BThread is not exposed in Javascript via bt (that was never used).
  • โœจ BThreads can now enqueue external events using bp.enqueueExternalEvent().
  • โœจ BThreads can now specify a function that will be executed if they are removed because an event in their breakUpon event set was selected. Use setBreakUponHandler( function(event){...} ).

Engine/General

  • โœจ Restructured the engine with JS proxies - javascript code has no direct interaction with the Java engine parts!
  • ๐Ÿ‘ More unit tests and examples

Engine/General

  • Restructured the engine with JS proxies - javascript code has no direct interaction with the Java engine parts!
  • More unit tests and examples

2016-06-11

  • โœจ BEvents now have an associated data object. See example here

  • โœจ New way of creating BEvents: a static method named named:

    new BEvent("1stEvent") // old
    BEvent.named("1stEvent") // new and English-like.

    Future usaged include the ability to reuse event instances, but we're not there yet.

  • โœจ Added support for Javascript definition of event sets:

    var sampleSet = bpjs.EventSet( function(e){
      return e.getName().startsWith("1st");
    } );

2016-06-10

  • โœจ Support for breakUpon in bsyncs:

    bsync( {request:A, waitFor:B, block:C, breakUpon:D})
  • โœจ SingleResourceBProgram - a convenience class for the common case of having a BProgram that consists of a single file.

2016-06-01

  • ๐Ÿ”„ BProgram's setupProgramScope gets a scope as parameter. So no need to call getGlobalScope, and it's clearer what to do.
  • โœจ RWBStatement now knows which BThread instantiated it
  • โœจ When a program deadlock, StreamLoggerListener would print the RWBStatements of all BThreads.

Legend:

  • ๐Ÿ”„ Change
  • โœจNew feature
  • ๐Ÿšฎ Deprecation
  • โฌ†๏ธ Upgrade
  • ๐Ÿ› Bug fix

About

Environment for running behavioral programs written in Javascript.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 88.9%
  • JavaScript 10.9%
  • Shell 0.2%